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 | 8427bffb9a89219977ee650396bae5971acec76d (patch) | |
tree | 5dd2882c209d897f7bcee08ce5996a2a503f0f60 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp | |
parent | d1ea9cd345f65b344c2fa54fd9a8e09858dbf1a4 (diff) | |
download | bcm5719-llvm-8427bffb9a89219977ee650396bae5971acec76d.tar.gz bcm5719-llvm-8427bffb9a89219977ee650396bae5971acec76d.zip |
* Finegrainify namespacification
* Transform: free <ty>* (cast <ty2>* X to <ty>*) into free <ty2>* X
llvm-svn: 10303
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index db178b3d1fd..80ae224f5d9 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/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 |