summaryrefslogtreecommitdiffstats
path: root/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index 4eb12c6..3a385cb 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -840,7 +840,15 @@ bool BitcodeReader::ParseMetadata() {
for (unsigned i = 1; i != RecordLength; ++i)
Name[i-1] = Record[i];
MetadataContext &TheMetadata = Context.getMetadata();
- TheMetadata.MDHandlerNames[Name.str()] = Kind;
+ unsigned ExistingKind = TheMetadata.getMDKind(Name.str());
+ if (ExistingKind == 0) {
+ unsigned NewKind = TheMetadata.registerMDKind(Name.str());
+ assert (Kind == NewKind
+ && "Unable to handle custom metadata mismatch!");
+ } else {
+ assert (ExistingKind == Kind
+ && "Unable to handle custom metadata mismatch!");
+ }
break;
}
}
@@ -1165,7 +1173,7 @@ bool BitcodeReader::ParseConstants() {
if (Record.size() < 2) return Error("Invalid INLINEASM record");
std::string AsmStr, ConstrStr;
bool HasSideEffects = Record[0] & 1;
- bool IsMsAsm = Record[0] >> 1;
+ bool IsAlignStack = Record[0] >> 1;
unsigned AsmStrSize = Record[1];
if (2+AsmStrSize >= Record.size())
return Error("Invalid INLINEASM record");
@@ -1179,7 +1187,7 @@ bool BitcodeReader::ParseConstants() {
ConstrStr += (char)Record[3+AsmStrSize+i];
const PointerType *PTy = cast<PointerType>(CurTy);
V = InlineAsm::get(cast<FunctionType>(PTy->getElementType()),
- AsmStr, ConstrStr, HasSideEffects, IsMsAsm);
+ AsmStr, ConstrStr, HasSideEffects, IsAlignStack);
break;
}
}
@@ -2044,14 +2052,18 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
}
case bitc::FUNC_CODE_INST_MALLOC: { // MALLOC: [instty, op, align]
+ // Autoupgrade malloc instruction to malloc call.
+ // FIXME: Remove in LLVM 3.0.
if (Record.size() < 3)
return Error("Invalid MALLOC record");
const PointerType *Ty =
dyn_cast_or_null<PointerType>(getTypeByID(Record[0]));
Value *Size = getFnValueByID(Record[1], Type::getInt32Ty(Context));
- unsigned Align = Record[2];
if (!Ty || !Size) return Error("Invalid MALLOC record");
- I = new MallocInst(Ty->getElementType(), Size, (1 << Align) >> 1);
+ if (!CurBB) return Error("Invalid malloc instruction with no BB");
+ const Type *Int32Ty = IntegerType::getInt32Ty(CurBB->getContext());
+ I = CallInst::CreateMalloc(CurBB, Int32Ty, Ty->getElementType(),
+ Size, NULL);
InstructionList.push_back(I);
break;
}
OpenPOWER on IntegriCloud