[llvm-commits] [llvm] r61240 - in /llvm/trunk/lib: AsmParser/LLLexer.cpp AsmParser/llvmAsmParser.y Bitcode/Reader/BitcodeReader.cpp Bitcode/Writer/BitcodeWriter.cpp VMCore/Attributes.cpp
Nick Lewycky
nicholas at mxc.ca
Fri Dec 19 01:38:47 PST 2008
Author: nicholas
Date: Fri Dec 19 03:38:31 2008
New Revision: 61240
URL: http://llvm.org/viewvc/llvm-project?rev=61240&view=rev
Log:
Commit missed files from nocapture change.
Modified:
llvm/trunk/lib/AsmParser/LLLexer.cpp
llvm/trunk/lib/AsmParser/llvmAsmParser.y
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/trunk/lib/VMCore/Attributes.cpp
Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=61240&r1=61239&r2=61240&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLLexer.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLLexer.cpp Fri Dec 19 03:38:31 2008
@@ -491,6 +491,7 @@
KEYWORD("nounwind", NOUNWIND);
KEYWORD("noreturn", NORETURN);
KEYWORD("noalias", NOALIAS);
+ KEYWORD("nocapture", NOCAPTURE);
KEYWORD("byval", BYVAL);
KEYWORD("nest", NEST);
KEYWORD("readnone", READNONE);
Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.y
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.y?rev=61240&r1=61239&r2=61240&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/llvmAsmParser.y (original)
+++ llvm/trunk/lib/AsmParser/llvmAsmParser.y Fri Dec 19 03:38:31 2008
@@ -1136,8 +1136,8 @@
%token <OtherOpVal> EXTRACTVALUE INSERTVALUE
// Function Attributes
-%token SIGNEXT ZEROEXT NORETURN INREG SRET NOUNWIND NOALIAS BYVAL NEST
-%token READNONE READONLY GC OPTSIZE NOINLINE ALWAYSINLINE SSP SSPREQ
+%token SIGNEXT ZEROEXT NORETURN INREG SRET NOUNWIND NOALIAS NOCAPTURE BYVAL
+%token READNONE READONLY GC OPTSIZE NOINLINE ALWAYSINLINE SSP SSPREQ NEST
// Visibility Styles
%token DEFAULT HIDDEN PROTECTED
@@ -1265,15 +1265,16 @@
CHECK_FOR_ERROR
};
-Attribute : ZEROEXT { $$ = Attribute::ZExt; }
- | ZEXT { $$ = Attribute::ZExt; }
- | SIGNEXT { $$ = Attribute::SExt; }
- | SEXT { $$ = Attribute::SExt; }
- | INREG { $$ = Attribute::InReg; }
- | SRET { $$ = Attribute::StructRet; }
- | NOALIAS { $$ = Attribute::NoAlias; }
- | BYVAL { $$ = Attribute::ByVal; }
- | NEST { $$ = Attribute::Nest; }
+Attribute : ZEROEXT { $$ = Attribute::ZExt; }
+ | ZEXT { $$ = Attribute::ZExt; }
+ | SIGNEXT { $$ = Attribute::SExt; }
+ | SEXT { $$ = Attribute::SExt; }
+ | INREG { $$ = Attribute::InReg; }
+ | SRET { $$ = Attribute::StructRet; }
+ | NOALIAS { $$ = Attribute::NoAlias; }
+ | NOCAPTURE { $$ = Attribute::NoCapture; }
+ | BYVAL { $$ = Attribute::ByVal; }
+ | NEST { $$ = Attribute::Nest; }
| ALIGN EUINT64VAL { $$ =
Attribute::constructAlignmentFromInt($2); }
;
@@ -1331,6 +1332,8 @@
$$ = $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; } |
@@ -1338,6 +1341,8 @@
$$ = $3;
if ($$ != 0 && !isPowerOf2_32($$))
GEN_ERROR("Alignment must be a power of two");
+ if ($$ > 0x40000000)
+ GEN_ERROR("Alignment too large");
CHECK_FOR_ERROR
};
@@ -1367,6 +1372,8 @@
| 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
};
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=61240&r1=61239&r2=61240&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Fri Dec 19 03:38:31 2008
@@ -362,6 +362,20 @@
Attributes RetAttribute = Attribute::None;
Attributes FnAttribute = Attribute::None;
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
+ // FIXME: remove in LLVM 3.0
+ // The alignment is stored as a 16-bit raw value from bits 31--16.
+ // We shift the bits above 31 down by 11 bits.
+
+ unsigned Alignment = (Record[i+1] & (0xffffull << 16)) >> 16;
+ if (Alignment && !isPowerOf2_32(Alignment))
+ return Error("Alignment is not a power of two.");
+
+ Attributes ReconstitutedAttr = Record[i+1] & 0xffff;
+ if (Alignment)
+ ReconstitutedAttr |= Attribute::constructAlignmentFromInt(Alignment);
+ ReconstitutedAttr |= (Record[i+1] & (0xffffull << 32)) >> 11;
+ Record[i+1] = ReconstitutedAttr;
+
if (Record[i] == 0)
RetAttribute = Record[i+1];
else if (Record[i] == ~0U)
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=61240&r1=61239&r2=61240&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Fri Dec 19 03:38:31 2008
@@ -122,7 +122,17 @@
for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i) {
const AttributeWithIndex &PAWI = A.getSlot(i);
Record.push_back(PAWI.Index);
- Record.push_back(PAWI.Attrs);
+
+ // FIXME: remove in LLVM 3.0
+ // Store the alignment in the bitcode as a 16-bit raw value instead of a
+ // 5-bit log2 encoded value. Shift the bits above the alignment up by
+ // 11 bits.
+ uint64_t FauxAttr = PAWI.Attrs & 0xffff;
+ if (PAWI.Attrs & Attribute::Alignment)
+ FauxAttr |= (1ull<<16)<<(((PAWI.Attrs & Attribute::Alignment)-1) >> 16);
+ FauxAttr |= (PAWI.Attrs & (0x3FFull << 21)) << 11;
+
+ Record.push_back(FauxAttr);
}
Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY, Record);
Modified: llvm/trunk/lib/VMCore/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Attributes.cpp?rev=61240&r1=61239&r2=61240&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Attributes.cpp (original)
+++ llvm/trunk/lib/VMCore/Attributes.cpp Fri Dec 19 03:38:31 2008
@@ -37,6 +37,8 @@
Result += "inreg ";
if (Attrs & Attribute::NoAlias)
Result += "noalias ";
+ if (Attrs & Attribute::NoCapture)
+ Result += "nocapture ";
if (Attrs & Attribute::StructRet)
Result += "sret ";
if (Attrs & Attribute::ByVal)
@@ -59,10 +61,11 @@
Result += "sspreq ";
if (Attrs & Attribute::Alignment) {
Result += "align ";
- Result += utostr((Attrs & Attribute::Alignment) >> 16);
+ Result += utostr(1ull << (((Attrs & Attribute::Alignment)>>16) - 1));
Result += " ";
}
// Trim the trailing space.
+ assert(!Result.empty() && "Unknown attribute!");
Result.erase(Result.end()-1);
return Result;
}
@@ -76,7 +79,7 @@
if (!isa<PointerType>(Ty))
// Attributes that only apply to pointers.
- Incompatible |= ByVal | Nest | NoAlias | StructRet;
+ Incompatible |= ByVal | Nest | NoAlias | StructRet | NoCapture;
return Incompatible;
}
More information about the llvm-commits
mailing list