aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorRuobing Han <hanruobing@gatech.edu>2022-07-19 21:39:14 +0000
committerRuobing Han <hanruobing@gatech.edu>2022-07-20 16:29:51 +0000
commit2b98b8e8fba1f7a7d11d099ecf2ebe1adc55b5aa (patch)
tree72ab2ae3ca32a4970e3dc2e231d6f43c19a7efa3 /llvm/lib/Transforms/Utils/Local.cpp
parent29a66ab7667786e2005637368de44f3751da1e23 (diff)
downloadllvm-2b98b8e8fba1f7a7d11d099ecf2ebe1adc55b5aa.zip
llvm-2b98b8e8fba1f7a7d11d099ecf2ebe1adc55b5aa.tar.gz
llvm-2b98b8e8fba1f7a7d11d099ecf2ebe1adc55b5aa.tar.bz2
fix bug for useless malloc elimination in CodeGenPrepare
Put AllocationFn check before I->willReturn can allow CodeGenPrepare to remove useless malloc instruction Differential Revision: https://reviews.llvm.org/D130126
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index b203259..9b1bb93 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -439,6 +439,9 @@ bool llvm::wouldInstructionBeTriviallyDead(Instruction *I,
return true;
}
+ if (isAllocationFn(I, TLI) && isAllocRemovable(cast<CallBase>(I), TLI))
+ return true;
+
if (!I->willReturn())
return false;
@@ -489,9 +492,6 @@ bool llvm::wouldInstructionBeTriviallyDead(Instruction *I,
}
}
- if (isAllocationFn(I, TLI) && isAllocRemovable(cast<CallBase>(I), TLI))
- return true;
-
if (CallInst *CI = isFreeCall(I, TLI))
if (Constant *C = dyn_cast<Constant>(CI->getArgOperand(0)))
return C->isNullValue() || isa<UndefValue>(C);