diff options
author | Chris Lattner <sabre@nondot.org> | 2003-12-07 01:24:23 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-12-07 01:24:23 +0000 |
commit | 67b1e1b89f221154ed6dd1ab895391789929ea2e (patch) | |
tree | 41553d6172b4bab94e15819646d612525de749da /lib/Transforms/Scalar | |
parent | eae45cf44bd1b9ddbb69865f1d46689e57e03417 (diff) | |
download | external_llvm-67b1e1b89f221154ed6dd1ab895391789929ea2e.zip external_llvm-67b1e1b89f221154ed6dd1ab895391789929ea2e.tar.gz external_llvm-67b1e1b89f221154ed6dd1ab895391789929ea2e.tar.bz2 |
* Finegrainify namespacification
* Transform: free <ty>* (cast <ty2>* X to <ty>*) into free <ty2>* X
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10303 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index db178b3..80ae224 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -48,8 +48,7 @@ #include "llvm/Support/CallSite.h" #include "Support/Statistic.h" #include <algorithm> - -namespace llvm { +using namespace llvm; namespace { Statistic<> NumCombined ("instcombine", "Number of insts combined"); @@ -104,6 +103,7 @@ namespace { Instruction *visitPHINode(PHINode &PN); Instruction *visitGetElementPtrInst(GetElementPtrInst &GEP); Instruction *visitAllocationInst(AllocationInst &AI); + Instruction *visitFreeInst(FreeInst &FI); Instruction *visitLoadInst(LoadInst &LI); Instruction *visitBranchInst(BranchInst &BI); @@ -2044,6 +2044,20 @@ Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) { return 0; } +Instruction *InstCombiner::visitFreeInst(FreeInst &FI) { + Value *Op = FI.getOperand(0); + + // Change free <ty>* (cast <ty2>* X to <ty>*) into free <ty2>* X + if (CastInst *CI = dyn_cast<CastInst>(Op)) + if (isa<PointerType>(CI->getOperand(0)->getType())) { + FI.setOperand(0, CI->getOperand(0)); + return &FI; + } + + return 0; +} + + /// GetGEPGlobalInitializer - Given a constant, and a getelementptr /// constantexpr, return the constant value being addressed by the constant /// expression, or null if something is funny. @@ -2196,8 +2210,7 @@ bool InstCombiner::runOnFunction(Function &F) { return Changed; } -Pass *createInstructionCombiningPass() { +Pass *llvm::createInstructionCombiningPass() { return new InstCombiner(); } -} // End llvm namespace |