summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-10-17 00:00:19 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-10-17 00:00:19 +0000
commitc7d6a8327c703297afc45391771975b2db9740ee (patch)
treeaded3b1bc0206680af43b37fe4a32a386e96deec /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent956127de22267e9ceb01f3464c1dd9f33acb6974 (diff)
downloadbcm5719-llvm-c7d6a8327c703297afc45391771975b2db9740ee.tar.gz
bcm5719-llvm-c7d6a8327c703297afc45391771975b2db9740ee.zip
Autoupgrade malloc insts to malloc calls.
Update testcases that rely on malloc insts being present. Also prematurely remove MallocInst handling from IndMemRemoval and RaiseAllocations to help pass tests in this incremental step. llvm-svn: 84292
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 4eb12c69eb6..fe4556f0a29 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2044,14 +2044,21 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
}
case bitc::FUNC_CODE_INST_MALLOC: { // MALLOC: [instty, op, align]
+ // Autoupgrade malloc instruction to malloc call.
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());
+ if (Size->getType() != Int32Ty)
+ Size = CastInst::CreateIntegerCast(Size, Int32Ty, false /*ZExt*/,
+ "", CurBB);
+ Value* Malloc = CallInst::CreateMalloc(CurBB, Int32Ty,
+ Ty->getElementType(), Size, NULL);
+ I = cast<Instruction>(Malloc);
InstructionList.push_back(I);
break;
}
OpenPOWER on IntegriCloud