mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
Update malloc call creation code (AllocType is now the element type of the malloc, not the resulting type).
In getMallocArraySize(), fix bug in the case that array size is the product of 2 constants. Extend isArrayMalloc() and getMallocArraySize() to handle case where malloc is used as char array. Ensure that ArraySize in LowerAllocations::runOnBasicBlock() is correct type. Extend Instruction::isSafeToSpeculativelyExecute() to handle malloc calls. Add verification for malloc calls. Reviewed by Dan Gohman. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82257 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -108,8 +108,12 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
|
||||
// Loop over all of the instructions, looking for malloc or free instructions
|
||||
for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) {
|
||||
if (MallocInst *MI = dyn_cast<MallocInst>(I)) {
|
||||
Value *MCast = CallInst::CreateMalloc(I, MI->getType(), IntPtrTy,
|
||||
MI->getOperand(0));
|
||||
Value *ArraySize = MI->getOperand(0);
|
||||
if (ArraySize->getType() != IntPtrTy)
|
||||
ArraySize = CastInst::CreateIntegerCast(ArraySize, IntPtrTy,
|
||||
false /*ZExt*/, "", I);
|
||||
Value *MCast = CallInst::CreateMalloc(I, IntPtrTy,
|
||||
MI->getAllocatedType(), ArraySize);
|
||||
|
||||
// Replace all uses of the old malloc inst with the cast inst
|
||||
MI->replaceAllUsesWith(MCast);
|
||||
|
Reference in New Issue
Block a user