diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2008-12-15 07:29:55 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2008-12-15 07:29:55 +0000 |
commit | 382da62ec274feead85e7be364ab5d4fd0281d98 (patch) | |
tree | 828ac242a7b39968f41a3bd9a76c0b5346eb12b0 /lib | |
parent | d17c0302763cfd0b3f6657d2493147552762ac07 (diff) | |
download | external_llvm-382da62ec274feead85e7be364ab5d4fd0281d98.zip external_llvm-382da62ec274feead85e7be364ab5d4fd0281d98.tar.gz external_llvm-382da62ec274feead85e7be364ab5d4fd0281d98.tar.bz2 |
It turns out that "align 1" and unaligned are different. Add a bias to the
alignment attribute such that 0 means unaligned.
This will probably require a rebuild of llvm-gcc because of the change to
Attributes.h. If you see many test failures on "make check", please rebuild
your llvm-gcc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61030 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AsmParser/llvmAsmParser.y | 6 | ||||
-rw-r--r-- | lib/Bitcode/Writer/BitcodeWriter.cpp | 3 | ||||
-rw-r--r-- | lib/VMCore/Attributes.cpp | 2 |
3 files changed, 9 insertions, 2 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index 350584f..7028ea3 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -1332,6 +1332,8 @@ OptAlign : /*empty*/ { $$ = 0; } | $$ = $2; if ($$ != 0 && !isPowerOf2_32($$)) GEN_ERROR("Alignment must be a power of two"); + if ($$ > 0x40000000) + GEN_ERROR("Alignment too large"); CHECK_FOR_ERROR }; OptCAlign : /*empty*/ { $$ = 0; } | @@ -1339,6 +1341,8 @@ OptCAlign : /*empty*/ { $$ = 0; } | $$ = $3; if ($$ != 0 && !isPowerOf2_32($$)) GEN_ERROR("Alignment must be a power of two"); + if ($$ > 0x40000000) + GEN_ERROR("Alignment too large"); CHECK_FOR_ERROR }; @@ -1368,6 +1372,8 @@ GlobalVarAttribute : SectionString { | ALIGN EUINT64VAL { if ($2 != 0 && !isPowerOf2_32($2)) GEN_ERROR("Alignment must be a power of two"); + if ($2 > 0x40000000) + GEN_ERROR("Alignment too large"); CurGV->setAlignment($2); CHECK_FOR_ERROR }; diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 0555ed9..adf49a5 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -128,7 +128,8 @@ static void WriteAttributeTable(const ValueEnumerator &VE, // 5-bit log2 encoded value. Shift the bits above the alignment up by // 11 bits. uint64_t FauxAttr = PAWI.Attrs & 0xffff; - FauxAttr |= (1ull<<16)<<((PAWI.Attrs & Attribute::Alignment) >> 16); + if (PAWI.Attrs & Attribute::Alignment) + FauxAttr |= (1ull<<16)<<(((PAWI.Attrs & Attribute::Alignment)-1) >> 16); FauxAttr |= (PAWI.Attrs & (0x3FFull << 21)) << 11; Record.push_back(FauxAttr); diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp index 0a0d0a8..dd47814 100644 --- a/lib/VMCore/Attributes.cpp +++ b/lib/VMCore/Attributes.cpp @@ -61,7 +61,7 @@ std::string Attribute::getAsString(Attributes Attrs) { Result += "sspreq "; if (Attrs & Attribute::Alignment) { Result += "align "; - Result += utostr(1ull << ((Attrs & Attribute::Alignment)>>16)); + Result += utostr(1ull << (((Attrs & Attribute::Alignment)>>16) - 1)); Result += " "; } // Trim the trailing space. |