aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-10-26 23:43:48 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-10-26 23:43:48 +0000
commit046e78ce55a7c3d82b7b6758d2d77f2d99f970bf (patch)
tree1dad2445d3c6c08dc6d901e27806df980a7f855a /lib/Transforms/Utils
parentdda9583e5194c08ddd409f3e1c211e17acd6d5b8 (diff)
Remove FreeInst.
Remove LowerAllocations pass. Update some more passes to treate free calls just like they were treating FreeInst. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85176 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/CMakeLists.txt1
-rw-r--r--lib/Transforms/Utils/Local.cpp5
-rw-r--r--lib/Transforms/Utils/LowerAllocations.cpp116
-rw-r--r--lib/Transforms/Utils/LowerInvoke.cpp1
-rw-r--r--lib/Transforms/Utils/LowerSwitch.cpp1
-rw-r--r--lib/Transforms/Utils/Mem2Reg.cpp1
6 files changed, 2 insertions, 123 deletions
diff --git a/lib/Transforms/Utils/CMakeLists.txt b/lib/Transforms/Utils/CMakeLists.txt
index f4394ea64d..fbc61d70e6 100644
--- a/lib/Transforms/Utils/CMakeLists.txt
+++ b/lib/Transforms/Utils/CMakeLists.txt
@@ -13,7 +13,6 @@ add_llvm_library(LLVMTransformUtils
LCSSA.cpp
Local.cpp
LoopSimplify.cpp
- LowerAllocations.cpp
LowerInvoke.cpp
LowerSwitch.cpp
Mem2Reg.cpp
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp
index 940f5a9ec4..6e18b66898 100644
--- a/lib/Transforms/Utils/Local.cpp
+++ b/lib/Transforms/Utils/Local.cpp
@@ -60,9 +60,8 @@ 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) || isFreeCall(BBI) ||
- (isa<CallInst>(BBI) && BBI->mayWriteToMemory() &&
- !isa<DbgInfoIntrinsic>(BBI)))
+ if (isFreeCall(BBI) || (isa<CallInst>(BBI) && BBI->mayWriteToMemory() &&
+ !isa<DbgInfoIntrinsic>(BBI)))
return false;
if (LoadInst *LI = dyn_cast<LoadInst>(BBI)) {
diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp
deleted file mode 100644
index 5f7bf4c766..0000000000
--- a/lib/Transforms/Utils/LowerAllocations.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-//===- LowerAllocations.cpp - Reduce free insts to calls ------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// The LowerAllocations transformation is a target-dependent tranformation
-// because it depends on the size of data types and alignment constraints.
-//
-//===----------------------------------------------------------------------===//
-
-#define DEBUG_TYPE "lowerallocs"
-#include "llvm/Transforms/Scalar.h"
-#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"
-#include "llvm/Module.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Instructions.h"
-#include "llvm/Constants.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/Pass.h"
-#include "llvm/ADT/Statistic.h"
-#include "llvm/Target/TargetData.h"
-using namespace llvm;
-
-STATISTIC(NumLowered, "Number of allocations lowered");
-
-namespace {
- /// LowerAllocations - Turn free instructions into @free calls.
- ///
- class LowerAllocations : public BasicBlockPass {
- Constant *FreeFunc; // Functions in the module we are processing
- // Initialized by doInitialization
- public:
- static char ID; // Pass ID, replacement for typeid
- explicit LowerAllocations()
- : BasicBlockPass(&ID), FreeFunc(0) {}
-
- virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- AU.addRequired<TargetData>();
- AU.setPreservesCFG();
-
- // This is a cluster of orthogonal Transforms:
- AU.addPreserved<UnifyFunctionExitNodes>();
- AU.addPreservedID(PromoteMemoryToRegisterID);
- AU.addPreservedID(LowerSwitchID);
- AU.addPreservedID(LowerInvokePassID);
- }
-
- /// doPassInitialization - For the lower allocations pass, this ensures that
- /// a module contains a declaration for a free function.
- ///
- bool doInitialization(Module &M);
-
- virtual bool doInitialization(Function &F) {
- return doInitialization(*F.getParent());
- }
-
- /// runOnBasicBlock - This method does the actual work of converting
- /// instructions over, assuming that the pass has already been initialized.
- ///
- bool runOnBasicBlock(BasicBlock &BB);
- };
-}
-
-char LowerAllocations::ID = 0;
-static RegisterPass<LowerAllocations>
-X("lowerallocs", "Lower allocations from instructions to calls");
-
-// Publically exposed interface to pass...
-const PassInfo *const llvm::LowerAllocationsID = &X;
-// createLowerAllocationsPass - Interface to this file...
-Pass *llvm::createLowerAllocationsPass() {
- return new LowerAllocations();
-}
-
-
-// doInitialization - For the lower allocations pass, this ensures that a
-// module contains a declaration for a free function.
-//
-// This function is always successful.
-//
-bool LowerAllocations::doInitialization(Module &M) {
- const Type *BPTy = Type::getInt8PtrTy(M.getContext());
- FreeFunc = M.getOrInsertFunction("free" , Type::getVoidTy(M.getContext()),
- BPTy, (Type *)0);
- return true;
-}
-
-// runOnBasicBlock - This method does the actual work of converting
-// instructions over, assuming that the pass has already been initialized.
-//
-bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
- bool Changed = false;
- assert(FreeFunc && "Pass not initialized!");
-
- BasicBlock::InstListType &BBIL = BB.getInstList();
-
- // 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)) {
- // Insert a call to the free function...
- CallInst::CreateFree(FI->getOperand(0), I);
-
- // Delete the old free instruction
- I = --BBIL.erase(I);
- Changed = true;
- ++NumLowered;
- }
- }
-
- return Changed;
-}
-
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp
index abb74146c7..6e6e8d2287 100644
--- a/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/lib/Transforms/Utils/LowerInvoke.cpp
@@ -86,7 +86,6 @@ namespace {
// This is a cluster of orthogonal Transforms
AU.addPreservedID(PromoteMemoryToRegisterID);
AU.addPreservedID(LowerSwitchID);
- AU.addPreservedID(LowerAllocationsID);
}
private:
diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp
index bc1779fd27..8c18b591a4 100644
--- a/lib/Transforms/Utils/LowerSwitch.cpp
+++ b/lib/Transforms/Utils/LowerSwitch.cpp
@@ -43,7 +43,6 @@ namespace {
AU.addPreserved<UnifyFunctionExitNodes>();
AU.addPreservedID(PromoteMemoryToRegisterID);
AU.addPreservedID(LowerInvokePassID);
- AU.addPreservedID(LowerAllocationsID);
}
struct CaseRange {
diff --git a/lib/Transforms/Utils/Mem2Reg.cpp b/lib/Transforms/Utils/Mem2Reg.cpp
index baa7d9ebff..941660436b 100644
--- a/lib/Transforms/Utils/Mem2Reg.cpp
+++ b/lib/Transforms/Utils/Mem2Reg.cpp
@@ -44,7 +44,6 @@ namespace {
AU.addPreserved<UnifyFunctionExitNodes>();
AU.addPreservedID(LowerSwitchID);
AU.addPreservedID(LowerInvokePassID);
- AU.addPreservedID(LowerAllocationsID);
}
};
} // end of anonymous namespace