X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTransforms%2FLevelRaise.cpp;h=cc684b5f150fa7f09d2169855a36f79dc2ac6909;hb=92deeaf7a32b1f537aea087322f0facdd2f459f4;hp=51d863d10df9cef5388340ff51046cb0f1b96b4b;hpb=237e6d10f24863cf48821b601b4164794e89d847;p=oota-llvm.git diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp index 51d863d10df..cc684b5f150 100644 --- a/lib/Transforms/LevelRaise.cpp +++ b/lib/Transforms/LevelRaise.cpp @@ -8,10 +8,8 @@ #include "llvm/Transforms/LevelChange.h" #include "TransformInternals.h" -#include "llvm/Function.h" #include "llvm/iOther.h" #include "llvm/iMemory.h" -#include "llvm/ConstantVals.h" #include "llvm/Pass.h" #include "llvm/ConstantHandling.h" #include "llvm/Transforms/Scalar/DCE.h" @@ -49,7 +47,6 @@ static inline bool isReinterpretingCast(const CastInst *CI) { } - // Peephole optimize the following instructions: // %t1 = cast ? to x * // %t2 = add x * %SP, %t1 ;; Constant must be 2nd operand @@ -193,26 +190,6 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) { return true; } - // Peephole optimize the following instructions: - // %tmp = cast %V to - // %V = cast %tmp to ; Where ty & ty2 are same size - // - // Into: cast %V to - // - if (SrcI) - if (CastInst *CSrc = dyn_cast(SrcI)) - if (isReinterpretingCast(CI) + isReinterpretingCast(CSrc) < 2) { - // We can only do c-c elimination if, at most, one cast does a - // reinterpretation of the input data. - // - // If legal, make this cast refer the the original casts argument! - // - PRINT_PEEPHOLE2("cast-cast:in ", CI, CSrc); - CI->setOperand(0, CSrc->getOperand(0)); - PRINT_PEEPHOLE1("cast-cast:out", CI); - return true; - } - // Check to see if it's a cast of an instruction that does not depend on the // specific type of the operands to do it's job. if (!isReinterpretingCast(CI)) { @@ -440,7 +417,7 @@ static bool DoRaisePass(Function *F) { } -// RaisePointerReferences::doit - Raise a method representation to a higher +// RaisePointerReferences::doit - Raise a function representation to a higher // level. // static bool doRPR(Function *F) { @@ -458,7 +435,7 @@ static bool doRPR(Function *F) { cerr << "Looping: \n" << F; #endif - // Iterate over the method, refining it, until it converges on a stable + // Iterate over the function, refining it, until it converges on a stable // state LocalChange = false; while (DoRaisePass(F)) LocalChange = true; @@ -470,8 +447,14 @@ static bool doRPR(Function *F) { } namespace { - struct RaisePointerReferences : public MethodPass { - virtual bool runOnMethod(Function *F) { return doRPR(F); } + struct RaisePointerReferences : public FunctionPass { + const char *getPassName() const { return "Raise Pointer References"; } + + virtual bool runOnFunction(Function *F) { return doRPR(F); } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.preservesCFG(); + } }; }