summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-10-24 04:23:03 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-10-24 04:23:03 +0000
commite297149e267e05159db4dc490493fddcb3784d95 (patch)
tree4f49152e0dfd1305070ba4ab33c516f5fe31ebab /llvm/lib/Transforms/Utils
parent46ed1f83414d1e93e5af6a8145526c0d216861c1 (diff)
downloadbcm5719-llvm-e297149e267e05159db4dc490493fddcb3784d95.tar.gz
bcm5719-llvm-e297149e267e05159db4dc490493fddcb3784d95.zip
Auto-upgrade free instructions to calls to the builtin free function.
Update all analysis passes and transforms to treat free calls just like FreeInst. Remove RaiseAllocations and all its tests since FreeInst no longer needs to be raised. llvm-svn: 84987
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp3
-rw-r--r--llvm/lib/Transforms/Utils/LowerAllocations.cpp6
2 files changed, 3 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index b62261119c7..940f5a9ec46 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -24,6 +24,7 @@
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/DebugInfo.h"
+#include "llvm/Analysis/MallocHelper.h"
#include "llvm/Analysis/ProfileInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
@@ -59,7 +60,7 @@ bool llvm::isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom) {
// If we see a free or a call which may write to memory (i.e. which might do
// a free) the pointer could be marked invalid.
- if (isa<FreeInst>(BBI) ||
+ if (isa<FreeInst>(BBI) || isFreeCall(BBI) ||
(isa<CallInst>(BBI) && BBI->mayWriteToMemory() &&
!isa<DbgInfoIntrinsic>(BBI)))
return false;
diff --git a/llvm/lib/Transforms/Utils/LowerAllocations.cpp b/llvm/lib/Transforms/Utils/LowerAllocations.cpp
index 9c9113daa93..f64a30f5e80 100644
--- a/llvm/lib/Transforms/Utils/LowerAllocations.cpp
+++ b/llvm/lib/Transforms/Utils/LowerAllocations.cpp
@@ -102,12 +102,8 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
// Loop over all of the instructions, looking for free instructions
for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) {
if (FreeInst *FI = dyn_cast<FreeInst>(I)) {
- Value *PtrCast =
- new BitCastInst(FI->getOperand(0),
- Type::getInt8PtrTy(BB.getContext()), "", I);
-
// Insert a call to the free function...
- CallInst::Create(FreeFunc, PtrCast, "", I)->setTailCall();
+ CallInst::CreateFree(FI->getOperand(0), I);
// Delete the old free instruction
I = --BBIL.erase(I);
OpenPOWER on IntegriCloud