diff options
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/ExprTypeConvert.cpp | 31 | ||||
-rw-r--r-- | lib/Transforms/HoistPHIConstants.cpp | 39 | ||||
-rw-r--r-- | lib/Transforms/IPO/ConstantMerge.cpp | 8 | ||||
-rw-r--r-- | lib/Transforms/IPO/DeadTypeElimination.cpp | 8 | ||||
-rw-r--r-- | lib/Transforms/IPO/InlineSimple.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/IPO/MutateStructTypes.cpp | 10 | ||||
-rw-r--r-- | lib/Transforms/Instrumentation/TraceValues.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/LevelRaise.cpp | 9 | ||||
-rw-r--r-- | lib/Transforms/Scalar/ConstantProp.cpp | 24 | ||||
-rw-r--r-- | lib/Transforms/Scalar/DCE.cpp | 6 | ||||
-rw-r--r-- | lib/Transforms/Scalar/InductionVars.cpp | 20 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SCCP.cpp | 46 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SymbolStripping.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/TransformInternals.cpp | 10 | ||||
-rw-r--r-- | lib/Transforms/TransformInternals.h | 8 | ||||
-rw-r--r-- | lib/Transforms/Utils/Linker.cpp | 32 | ||||
-rw-r--r-- | lib/Transforms/Utils/LowerAllocations.cpp | 4 |
17 files changed, 129 insertions, 134 deletions
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp index 7efe6238be..57d533d88d 100644 --- a/lib/Transforms/ExprTypeConvert.cpp +++ b/lib/Transforms/ExprTypeConvert.cpp @@ -11,7 +11,7 @@ #include "llvm/iOther.h" #include "llvm/iPHINode.h" #include "llvm/iMemory.h" -#include "llvm/ConstPoolVals.h" +#include "llvm/ConstantVals.h" #include "llvm/Optimizations/ConstantHandling.h" #include "llvm/Optimizations/DCE.h" #include "llvm/Analysis/Expressions.h" @@ -36,7 +36,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, static bool AllIndicesZero(const MemAccessInst *MAI) { for (User::op_const_iterator S = MAI->idx_begin(), E = MAI->idx_end(); S != E; ++S) - if (!isa<ConstPoolVal>(*S) || !cast<ConstPoolVal>(*S)->isNullValue()) + if (!isa<Constant>(*S) || !cast<Constant>(*S)->isNullValue()) return false; return true; } @@ -155,7 +155,7 @@ static Instruction *ConvertMallocToType(MallocInst *MI, const Type *Ty, unsigned DataSize = TD.getTypeSize(ElType); if (OffsetAmount > DataSize) // Allocate a sized array amount... - Expr.Var = ConstPoolUInt::get(Type::UIntTy, OffsetAmount/DataSize); + Expr.Var = ConstantUInt::get(Type::UIntTy, OffsetAmount/DataSize); } #endif @@ -198,7 +198,7 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty, // const prop'd in general). We just ask the constant propogator to see if // it can convert the value... // - if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(V)) + if (Constant *CPV = dyn_cast<Constant>(V)) if (opt::ConstantFoldCastInstruction(CPV, Ty)) return true; // Don't worry about deallocating, it's a constant. @@ -285,8 +285,8 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty, const Type *BaseType = GEP->getPointerOperand()->getType(); const Type *ElTy = 0; - while (!Indices.empty() && isa<ConstPoolUInt>(Indices.back()) && - cast<ConstPoolUInt>(Indices.back())->getValue() == 0) { + while (!Indices.empty() && isa<ConstantUInt>(Indices.back()) && + cast<ConstantUInt>(Indices.back())->getValue() == 0) { Indices.pop_back(); ElTy = GetElementPtrInst::getIndexedType(BaseType, Indices, true); @@ -329,7 +329,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) { Instruction *I = dyn_cast<Instruction>(V); if (I == 0) - if (ConstPoolVal *CPV = cast<ConstPoolVal>(V)) { + if (Constant *CPV = cast<Constant>(V)) { // Constants are converted by constant folding the cast that is required. // We assume here that all casts are implemented for constant prop. Value *Result = opt::ConstantFoldCastInstruction(CPV, Ty); @@ -349,7 +349,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) { ValueHandle IHandle(VMC, I); // Prevent I from being removed! - ConstPoolVal *Dummy = ConstPoolVal::getNullConstant(Ty); + Constant *Dummy = Constant::getNullConstant(Ty); //cerr << endl << endl << "Type:\t" << Ty << "\nInst: " << I << "BB Before: " << BB << endl; @@ -380,8 +380,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) { LoadInst *LI = cast<LoadInst>(I); assert(!LI->hasIndices() || AllIndicesZero(LI)); - Res = new LoadInst(ConstPoolVal::getNullConstant(PointerType::get(Ty)), - Name); + Res = new LoadInst(Constant::getNullConstant(PointerType::get(Ty)), Name); VMC.ExprMap[I] = Res; Res->setOperand(0, ConvertExpressionToType(LI->getPointerOperand(), PointerType::get(Ty), VMC)); @@ -433,8 +432,8 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) { const Type *BaseType = GEP->getPointerOperand()->getType(); const Type *PVTy = cast<PointerType>(Ty)->getValueType(); Res = 0; - while (!Indices.empty() && isa<ConstPoolUInt>(Indices.back()) && - cast<ConstPoolUInt>(Indices.back())->getValue() == 0) { + while (!Indices.empty() && isa<ConstantUInt>(Indices.back()) && + cast<ConstantUInt>(Indices.back())->getValue() == 0) { Indices.pop_back(); if (GetElementPtrInst::getIndexedType(BaseType, Indices, true) == PVTy) { if (Indices.size() == 0) { @@ -723,8 +722,8 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, ValueHandle IHandle(VMC, I); const Type *NewTy = NewVal->getType(); - ConstPoolVal *Dummy = (NewTy != Type::VoidTy) ? - ConstPoolVal::getNullConstant(NewTy) : 0; + Constant *Dummy = (NewTy != Type::VoidTy) ? + Constant::getNullConstant(NewTy) : 0; switch (I->getOpcode()) { case Instruction::Cast: @@ -793,12 +792,12 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, case Instruction::Store: { if (I->getOperand(0) == OldVal) { // Replace the source value const PointerType *NewPT = PointerType::get(NewTy); - Res = new StoreInst(NewVal, ConstPoolVal::getNullConstant(NewPT)); + Res = new StoreInst(NewVal, Constant::getNullConstant(NewPT)); VMC.ExprMap[I] = Res; Res->setOperand(1, ConvertExpressionToType(I->getOperand(1), NewPT, VMC)); } else { // Replace the source pointer const Type *ValTy = cast<PointerType>(NewTy)->getValueType(); - Res = new StoreInst(ConstPoolVal::getNullConstant(ValTy), NewVal); + Res = new StoreInst(Constant::getNullConstant(ValTy), NewVal); VMC.ExprMap[I] = Res; Res->setOperand(0, ConvertExpressionToType(I->getOperand(0), ValTy, VMC)); } diff --git a/lib/Transforms/HoistPHIConstants.cpp b/lib/Transforms/HoistPHIConstants.cpp index fe7cabf161..e28e8a2fe4 100644 --- a/lib/Transforms/HoistPHIConstants.cpp +++ b/lib/Transforms/HoistPHIConstants.cpp @@ -51,32 +51,29 @@ bool HoistPHIConstants::doHoistPHIConstants(Method *M) { CachedCopyMap Cache; bool Changed = false; - for (Method::iterator BI = M->begin(), BE = M->end(); BI != BE; ++BI) - { - vector<PHINode*> phis; // normalizing invalidates BB iterator + for (Method::iterator BI = M->begin(), BE = M->end(); BI != BE; ++BI) { + vector<PHINode*> phis; // normalizing invalidates BB iterator - for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II) - { - if (PHINode *PN = dyn_cast<PHINode>(*II)) - phis.push_back(PN); - else - break; // All PHIs occur at top of BB! - } + for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II) { + if (PHINode *PN = dyn_cast<PHINode>(*II)) + phis.push_back(PN); + else + break; // All PHIs occur at top of BB! + } - for (vector<PHINode*>::iterator PI=phis.begin(); PI != phis.end(); ++PI) - for (unsigned i = 0; i < (*PI)->getNumIncomingValues(); ++i) - { - Value *Op = (*PI)->getIncomingValue(i); - - if (isa<ConstPoolVal>(Op)) { - (*PI)->setIncomingValue(i, + for (vector<PHINode*>::iterator PI=phis.begin(); PI != phis.end(); ++PI) + for (unsigned i = 0; i < (*PI)->getNumIncomingValues(); ++i) { + Value *Op = (*PI)->getIncomingValue(i); + + if (isa<Constant>(Op)) { + (*PI)->setIncomingValue(i, NormalizePhiOperand((*PI), (*PI)->getIncomingValue(i), (*PI)->getIncomingBlock(i), Cache)); - Changed = true; - } - } - } + Changed = true; + } + } + } return Changed; } diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index 3564a814c8..70e3437bb9 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -23,7 +23,7 @@ // static inline bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo, - map<ConstPoolVal*, GlobalVariable*> &CMap) { + map<Constant*, GlobalVariable*> &CMap) { Module::GlobalListType &GList = M->getGlobalList(); if (GList.size() <= ConstantNo) return false; // No new constants bool MadeChanges = false; @@ -32,10 +32,10 @@ bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo, GlobalVariable *GV = GList[ConstantNo]; if (GV->isConstant()) { // Only process constants assert(GV->hasInitializer() && "Globals constants must have inits!"); - ConstPoolVal *Init = GV->getInitializer(); + Constant *Init = GV->getInitializer(); // Check to see if the initializer is already known... - map<ConstPoolVal*, GlobalVariable*>::iterator I = CMap.find(Init); + map<Constant*, GlobalVariable*>::iterator I = CMap.find(Init); if (I == CMap.end()) { // Nope, add it to the map CMap.insert(make_pair(Init, GV)); @@ -59,7 +59,7 @@ bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo, // deal with passes. // bool ConstantMerge::mergeDuplicateConstants(Module *M) { - map<ConstPoolVal*, GlobalVariable*> Constants; + map<Constant*, GlobalVariable*> Constants; unsigned LastConstantSeen = 0; return ::mergeDuplicateConstants(M, LastConstantSeen, Constants); } diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index f29ae29e0b..8599118c38 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -458,13 +458,13 @@ static inline void CheckIncomingValueFor(PHINode *PN, BasicBlock *BB) { const Type *Ty = PN->getType(); if (const PointerType *PT = dyn_cast<PointerType>(Ty)) - NewVal = ConstPoolPointerNull::get(PT); + NewVal = ConstantPointerNull::get(PT); else if (Ty == Type::BoolTy) - NewVal = ConstPoolBool::True; + NewVal = ConstantBool::True; else if (Ty == Type::FloatTy || Ty == Type::DoubleTy) - NewVal = ConstPoolFP::get(Ty, 42); + NewVal = ConstantFP::get(Ty, 42); else if (Ty->isIntegral()) - NewVal = ConstPoolInt::get(Ty, 42); + NewVal = ConstantInt::get(Ty, 42); assert(NewVal && "Unknown PHI node type!"); PN->addIncoming(NewVal, BB); diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index e54e0d9b7f..40b98bd67d 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -41,7 +41,7 @@ static inline void RemapInstruction(Instruction *I, for (unsigned op = 0, E = I->getNumOperands(); op != E; ++op) { const Value *Op = I->getOperand(op); Value *V = ValueMap[Op]; - if (!V && (isa<GlobalValue>(Op) || isa<ConstPoolVal>(Op))) + if (!V && (isa<GlobalValue>(Op) || isa<Constant>(Op))) continue; // Globals and constants don't get relocated if (!V) { diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp index a433e26ec5..c9f7917bd9 100644 --- a/lib/Transforms/IPO/MutateStructTypes.cpp +++ b/lib/Transforms/IPO/MutateStructTypes.cpp @@ -115,7 +115,7 @@ void MutateStructTypes::AdjustIndices(const CompositeType *OldTy, if (const StructType *OldST = dyn_cast<StructType>(OldTy)) { // Figure out what the current index is... - unsigned ElNum = cast<ConstPoolUInt>(Idx[i])->getValue(); + unsigned ElNum = cast<ConstantUInt>(Idx[i])->getValue(); assert(ElNum < OldST->getElementTypes().size()); map<const StructType*, TransformType>::iterator I = Transforms.find(OldST); @@ -123,7 +123,7 @@ void MutateStructTypes::AdjustIndices(const CompositeType *OldTy, assert(ElNum < I->second.second.size()); // Apply the XForm specified by Transforms map... unsigned NewElNum = I->second.second[ElNum]; - Idx[i] = ConstPoolUInt::get(Type::UByteTy, NewElNum); + Idx[i] = ConstantUInt::get(Type::UByteTy, NewElNum); } } @@ -140,12 +140,12 @@ Value *MutateStructTypes::ConvertValue(const Value *V) { // Ignore null values and simple constants.. if (V == 0) return 0; - if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(V)) { + if (Constant *CPV = dyn_cast<Constant>(V)) { if (V->getType()->isPrimitiveType()) return CPV; - if (isa<ConstPoolPointerNull>(CPV)) - return ConstPoolPointerNull::get( + if (isa<ConstantPointerNull>(CPV)) + return ConstantPointerNull::get( cast<PointerType>(ConvertType(V->getType()))); assert(0 && "Unable to convert constpool val of this type!"); } diff --git a/lib/Transforms/Instrumentation/TraceValues.cpp b/lib/Transforms/Instrumentation/TraceValues.cpp index 07db02854e..b42bb7bf6d 100644 --- a/lib/Transforms/Instrumentation/TraceValues.cpp +++ b/lib/Transforms/Instrumentation/TraceValues.cpp @@ -15,7 +15,7 @@ #include "llvm/Transforms/Instrumentation/TraceValues.h" #include "llvm/GlobalVariable.h" -#include "llvm/ConstPoolVals.h" +#include "llvm/ConstantVals.h" #include "llvm/Type.h" #include "llvm/DerivedTypes.h" #include "llvm/Instruction.h" @@ -68,7 +68,7 @@ PrintMethodNameForType(const Type* type) } static inline GlobalVariable *GetStringRef(Module *M, const string &str) { - ConstPoolArray *Init = ConstPoolArray::get(str); + ConstantArray *Init = ConstantArray::get(str); GlobalVariable *GV = new GlobalVariable(Init->getType(), /*Const*/true, /*intern*/true, Init); M->getGlobalList().push_back(GV); diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp index f80270567d..e0ca4dbfb0 100644 --- a/lib/Transforms/LevelRaise.cpp +++ b/lib/Transforms/LevelRaise.cpp @@ -11,7 +11,7 @@ #include "llvm/Method.h" #include "llvm/iOther.h" #include "llvm/iMemory.h" -#include "llvm/ConstPoolVals.h" +#include "llvm/ConstantVals.h" #include "llvm/Optimizations/ConstantHandling.h" #include "llvm/Optimizations/DCE.h" #include "llvm/Optimizations/ConstantProp.h" @@ -175,7 +175,7 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) { #endif ValueMapCache ValueMap; Value *E = ConvertExpressionToType(Src, DestTy, ValueMap); - if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(E)) + if (Constant *CPV = dyn_cast<Constant>(E)) CI->replaceAllUsesWith(CPV); BI = BB->begin(); // Rescan basic block. BI might be invalidated. @@ -242,7 +242,7 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) { } // Insert a zero to index through this type... - Indices.push_back(ConstPoolUInt::get(CurCTy->getIndexType(), 0)); + Indices.push_back(ConstantUInt::get(CurCTy->getIndexType(), 0)); // Did we find what we're looking for? if (ElTy->isLosslesslyConvertableTo(DestPointedTy)) break; @@ -502,8 +502,7 @@ static bool DoInsertArrayCast(Value *V, BasicBlock *BB, // Insert a cast! CastInst *TheCast = - new CastInst(ConstPoolVal::getNullConstant(V->getType()), DestTy, - V->getName()); + new CastInst(Constant::getNullConstant(V->getType()), DestTy, V->getName()); BB->getInstList().insert(InsertBefore, TheCast); cerr << "Inserting cast for " << V << endl; diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp index bf2886871f..4fb3254853 100644 --- a/lib/Transforms/Scalar/ConstantProp.cpp +++ b/lib/Transforms/Scalar/ConstantProp.cpp @@ -29,12 +29,12 @@ #include "llvm/iTerminators.h" #include "llvm/iPHINode.h" #include "llvm/iOther.h" -#include "llvm/ConstPoolVals.h" +#include "llvm/ConstantVals.h" inline static bool ConstantFoldUnaryInst(BasicBlock *BB, BasicBlock::iterator &II, - UnaryOperator *Op, ConstPoolVal *D) { - ConstPoolVal *ReplaceWith = + UnaryOperator *Op, Constant *D) { + Constant *ReplaceWith = opt::ConstantFoldUnaryInstruction(Op->getOpcode(), D); if (!ReplaceWith) return false; // Nothing new to change... @@ -56,8 +56,8 @@ ConstantFoldUnaryInst(BasicBlock *BB, BasicBlock::iterator &II, inline static bool ConstantFoldCast(BasicBlock *BB, BasicBlock::iterator &II, - CastInst *CI, ConstPoolVal *D) { - ConstPoolVal *ReplaceWith = + CastInst *CI, Constant *D) { + Constant *ReplaceWith = opt::ConstantFoldCastInstruction(D, CI->getType()); if (!ReplaceWith) return false; // Nothing new to change... @@ -80,8 +80,8 @@ ConstantFoldCast(BasicBlock *BB, BasicBlock::iterator &II, inline static bool ConstantFoldBinaryInst(BasicBlock *BB, BasicBlock::iterator &II, BinaryOperator *Op, - ConstPoolVal *D1, ConstPoolVal *D2) { - ConstPoolVal *ReplaceWith = + Constant *D1, Constant *D2) { + Constant *ReplaceWith = opt::ConstantFoldBinaryInstruction(Op->getOpcode(), D1, D2); if (!ReplaceWith) return false; // Nothing new to change... @@ -111,7 +111,7 @@ bool opt::ConstantFoldTerminator(TerminatorInst *T) { BasicBlock *Dest1 = cast<BasicBlock>(BI->getOperand(0)); BasicBlock *Dest2 = cast<BasicBlock>(BI->getOperand(1)); - if (ConstPoolBool *Cond = dyn_cast<ConstPoolBool>(BI->getCondition())) { + if (ConstantBool *Cond = dyn_cast<ConstantBool>(BI->getCondition())) { // Are we branching on constant? // YES. Change to unconditional branch... BasicBlock *Destination = Cond->getValue() ? Dest1 : Dest2; @@ -160,18 +160,18 @@ bool opt::ConstantPropogation::doConstantPropogation(BasicBlock *BB, BasicBlock::iterator &II) { Instruction *Inst = *II; if (BinaryOperator *BInst = dyn_cast<BinaryOperator>(Inst)) { - ConstPoolVal *D1 = dyn_cast<ConstPoolVal>(Inst->getOperand(0)); - ConstPoolVal *D2 = dyn_cast<ConstPoolVal>(Inst->getOperand(1)); + Constant *D1 = dyn_cast<Constant>(Inst->getOperand(0)); + Constant *D2 = dyn_cast<Constant>(Inst->getOperand(1)); if (D1 && D2) return ConstantFoldBinaryInst(BB, II, cast<BinaryOperator>(Inst), D1, D2); } else if (CastInst *CI = dyn_cast<CastInst>(Inst)) { - ConstPoolVal *D = dyn_cast<ConstPoolVal>(CI->getOperand(0)); + Constant *D = dyn_cast<Constant>(CI->getOperand(0)); if (D) return ConstantFoldCast(BB, II, CI, D); } else if (UnaryOperator *UInst = dyn_cast<UnaryOperator>(Inst)) { - ConstPoolVal *D = dyn_cast<ConstPoolVal>(UInst->getOperand(0)); + Constant *D = dyn_cast<Constant>(UInst->getOperand(0)); if (D) return ConstantFoldUnaryInst(BB, II, UInst, D); } else if (TerminatorInst *TInst = dyn_cast<TerminatorInst>(Inst)) { return opt::ConstantFoldTerminator(TInst); diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp index e1bda22b8b..6c4e3d2a20 100644 --- a/lib/Transforms/Scalar/DCE.cpp +++ b/lib/Transforms/Scalar/DCE.cpp @@ -96,7 +96,7 @@ static bool RemoveSingularPHIs(BasicBlock *BB) { } static void ReplaceUsesWithConstant(Instruction *I) { - ConstPoolVal *CPV = ConstPoolVal::getNullConstant(I->getType()); + Constant *CPV = Constant::getNullConstant(I->getType()); // Make all users of this instruction reference the constant instead I->replaceAllUsesWith(CPV); @@ -166,7 +166,7 @@ bool opt::SimplifyCFG(Method::iterator &BBIt) { // Remove basic blocks that have no predecessors... which are unreachable. if (BB->pred_begin() == BB->pred_end() && - !BB->hasConstantPoolReferences()) { + !BB->hasConstantReferences()) { //cerr << "Removing BB: \n" << BB; // Loop through all of our successors and make sure they know that one @@ -225,7 +225,7 @@ bool opt::SimplifyCFG(Method::iterator &BBIt) { // and if there is only one successor of the predecessor. BasicBlock::pred_iterator PI(BB->pred_begin()); if (PI != BB->pred_end() && *PI != BB && // Not empty? Not same BB? - ++PI == BB->pred_end() && !BB->hasConstantPoolReferences()) { + ++PI == BB->pred_end() && !BB->hasConstantReferences()) { BasicBlock *Pred = *BB->pred_begin(); TerminatorInst *Term = Pred->getTerminator(); assert(Term != 0 && "malformed basic block without terminator!"); diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp index 7dfae486d2..d4b7bc5010 100644 --- a/lib/Transforms/Scalar/InductionVars.cpp +++ b/lib/Transforms/Scalar/InductionVars.cpp @@ -20,7 +20,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Optimizations/InductionVars.h" -#include "llvm/ConstPoolVals.h" +#include "llvm/ConstantVals.h" #include "llvm/Analysis/IntervalPartition.h" #include "llvm/Assembly/Writer.h" #include "llvm/SymbolTable.h" @@ -36,7 +36,7 @@ using namespace opt; // an interval invariant computation. // static bool isLoopInvariant(cfg::Interval *Int, Value *V) { - assert(isa<ConstPoolVal>(V) || isa<Instruction>(V) || isa<MethodArgument>(V)); + assert(isa<Constant>(V) || isa<Instruction>(V) || isa<MethodArgument>(V)); if (!isa<Instruction>(V)) return true; // Constants and arguments are always loop invariant @@ -132,12 +132,12 @@ static inline bool isLinearInductionVariable(cfg::Interval *Int, Value *V, static inline bool isSimpleInductionVar(PHINode *PN) { assert(PN->getNumIncomingValues() == 2 && "Must have cannonical PHI node!"); Value *Initializer = PN->getIncomingValue(0); - if (!isa<ConstPoolVal>(Initializer)) return false; + if (!isa<Constant>(Initializer)) return false; if (Initializer->getType()->isSigned()) { // Signed constant value... - if (((ConstPoolSInt*)Initializer)->getValue() != 0) return false; + if (((ConstantSInt*)Initializer)->getValue() != 0) return false; } else if (Initializer->getType()->isUnsigned()) { // Unsigned constant value - if (((ConstPoolUInt*)Initializer)->getValue() != 0) return false; + if (((ConstantUInt*)Initializer)->getValue() != 0) return false; } else { return false; // Not signed or unsigned? Must be FP type or something } @@ -153,12 +153,12 @@ static inline bool isSimpleInductionVar(PHINode *PN) { // Get the right hand side of the ADD node. See if it is a constant 1. Value *StepSize = I->getOperand(1); - if (!isa<ConstPoolVal>(StepSize)) return false; + if (!isa<Constant>(StepSize)) return false; if (StepSize->getType()->isSigned()) { // Signed constant value... - if (((ConstPoolSInt*)StepSize)->getValue() != 1) return false; + if (((ConstantSInt*)StepSize)->getValue() != 1) return false; } else if (StepSize->getType()->isUnsigned()) { // Unsigned constant value - if (((ConstPoolUInt*)StepSize)->getValue() != 1) return false; + if (((ConstantUInt*)StepSize)->getValue() != 1) return false; } else { return false; // Not signed or unsigned? Must be FP type or something } @@ -189,8 +189,8 @@ static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) { // Create the neccesary instructions... PHINode *PN = new PHINode(Type::UIntTy, PHIName); - ConstPoolVal *One = ConstPoolUInt::get(Type::UIntTy, 1); - ConstPoolVal *Zero = ConstPoolUInt::get(Type::UIntTy, 0); + Constant *One = ConstantUInt::get(Type::UIntTy, 1); + Constant *Zero = ConstantUInt::get(Type::UIntTy, 0); BinaryOperator *AddNode = BinaryOperator::create(Instruction::Add, PN, One, AddName); diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 3c699c16e0..26a52d61bf 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -19,7 +19,7 @@ #include "llvm/Optimizations/ConstantHandling.h" #include "llvm/Method.h" #include "llvm/BasicBlock.h" -#include "llvm/ConstPoolVals.h" +#include "llvm/ConstantVals.h" #include "llvm/InstrTypes.h" #include "llvm/iPHINode.h" #include "llvm/iMemory.h" @@ -38,28 +38,28 @@ // class InstVal { enum { - Undefined, // This instruction has no known value - Constant, // This instruction has a constant value + undefined, // This instruction has no known value + constant, // This instruction has a constant value // Range, // This instruction is known to fall within a range - Overdefined // This instruction has an unknown value - } LatticeValue; // The current lattice position - ConstPoolVal *ConstantVal; // If Constant value, the current value + overdefined // This instruction has an unknown value + } LatticeValue; // The current lattice position + Constant *ConstantVal; // If Constant value, the current value public: - inline InstVal() : LatticeValue(Undefined), ConstantVal(0) {} + inline InstVal() : LatticeValue(undefined), ConstantVal(0) {} // markOverdefined - Return true if this is a new status to be in... inline bool markOverdefined() { - if (LatticeValue != Overdefined) { - LatticeValue = Overdefined; + if (LatticeValue != overdefined) { + LatticeValue = overdefined; return true; } return false; } // markConstant - Return true if this is a new status for us... - inline bool markConstant(ConstPoolVal *V) { - if (LatticeValue != Constant) { - LatticeValue = Constant; + inline bool markConstant(Constant *V) { + if (LatticeValue != constant) { + LatticeValue = constant; ConstantVal = V; return true; } else { @@ -68,11 +68,11 @@ public: return false; } - inline bool isUndefined() const { return LatticeValue == Undefined; } - inline bool isConstant() const { return LatticeValue == Constant; } - inline bool isOverdefined() const { return LatticeValue == Overdefined; } + inline bool isUndefined() const { return LatticeValue == undefined; } + inline bool isConstant() const { return LatticeValue == constant; } + inline bool isOverdefined() const { return LatticeValue == overdefined; } - inline ConstPoolVal *getConstant() const { return ConstantVal; } + inline Constant *getConstant() const { return ConstantVal; } }; @@ -113,7 +113,7 @@ private: // is not already a constant, add it to the instruction work list so that // the users of the instruction are updated later. // - inline bool markConstant(Instruction *I, ConstPoolVal *V) { + inline bool markConstant(Instruction *I, Constant *V) { //cerr << "markConstant: " << V << " = " << I; if (ValueState[I].markConstant(V)) { InstWorkList.push_back(I); @@ -147,7 +147,7 @@ private: map<Value*, InstVal>::iterator I = ValueState.find(V); if (I != ValueState.end()) return I->second; // Common case, in the map - if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(V)) {//Constants are constant + if (Constant *CPV = dyn_cast<Constant>(V)) { // Constants are constant ValueState[CPV].markConstant(CPV); } else if (isa<MethodArgument>(V)) { // MethodArgs are overdefined ValueState[V].markOverdefined(); @@ -246,7 +246,7 @@ bool SCCP::doSCCP() { Instruction *Inst = *II; InstVal &IV = ValueState[Inst]; if (IV.isConstant()) { - ConstPoolVal *Const = IV.getConstant(); + Constant *Const = IV.getConstant(); // cerr << "Constant: " << Inst << " is: " << Const; // Replaces all of the uses of a variable with uses of the constant. @@ -393,7 +393,7 @@ void SCCP::UpdateInstruction(Instruction *I) { markExecutable(BI->getSuccessor(1)); } else if (BCValue.isConstant()) { // Constant condition variables mean the branch can only go a single way. - ConstPoolBool *CPB = cast<ConstPoolBool>(BCValue.getConstant()); + ConstantBool *CPB = cast<ConstantBool>(BCValue.getConstant()); if (CPB->getValue()) // If the branch condition is TRUE... markExecutable(BI->getSuccessor(0)); else // Else if the br cond is FALSE... @@ -409,7 +409,7 @@ void SCCP::UpdateInstruction(Instruction *I) { for(unsigned i = 0; BasicBlock *Succ = SI->getSuccessor(i); ++i) markExecutable(Succ); } else if (SCValue.isConstant()) { - ConstPoolVal *CPV = SCValue.getConstant(); + Constant *CPV = SCValue.getConstant(); // Make sure to skip the "default value" which isn't a value for (unsigned i = 1, E = SI->getNumSuccessors(); i != E; ++i) { if (SI->getSuccessorValue(i) == CPV) {// Found the right branch... @@ -443,7 +443,7 @@ void SCCP::UpdateInstruction(Instruction *I) { if (VState.isOverdefined()) { // Inherit overdefinedness of operand markOverdefined(I); } else if (VState.isConstant()) { // Propogate constant value - ConstPoolVal *Result = isa<CastInst>(I) + Constant *Result = isa<CastInst>(I) ? opt::ConstantFoldCastInstruction(VState.getConstant(), I->getType()) : opt::ConstantFoldUnaryInstruction(I->getOpcode(), VState.getConstant()); @@ -470,7 +470,7 @@ void SCCP::UpdateInstruction(Instruction *I) { if (V1State.isOverdefined() || V2State.isOverdefined()) { markOverdefined(I); } else if (V1State.isConstant() && V2State.isConstant()) { - ConstPoolVal *Result = + Constant *Result = opt::ConstantFoldBinaryInstruction(I->getOpcode(), V1State.getConstant(), V2State.getConstant()); diff --git a/lib/Transforms/Scalar/SymbolStripping.cpp b/lib/Transforms/Scalar/SymbolStripping.cpp index 06cf025221..bb4f01c90b 100644 --- a/lib/Transforms/Scalar/SymbolStripping.cpp +++ b/lib/Transforms/Scalar/SymbolStripping.cpp @@ -29,7 +29,7 @@ static bool StripSymbolTable(SymbolTable *SymTab) { SymbolTable::type_iterator B; while ((B = Plane.begin()) != Plane.end()) { // Found nonempty type plane! Value *V = B->second; - if (isa<ConstPoolVal>(V) || isa<Type>(V)) + if (isa<Constant>(V) || isa<Type>(V)) SymTab->type_remove(B); else V->setName("", SymTab); // Set name to "", removing from symbol table! diff --git a/lib/Transforms/TransformInternals.cpp b/lib/Transforms/TransformInternals.cpp index dbe5ea9b66..5fdffda908 100644 --- a/lib/Transforms/TransformInternals.cpp +++ b/lib/Transforms/TransformInternals.cpp @@ -8,7 +8,7 @@ #include "TransformInternals.h" #include "llvm/Method.h" #include "llvm/Type.h" -#include "llvm/ConstPoolVals.h" +#include "llvm/ConstantVals.h" #include "llvm/Analysis/Expressions.h" #include "llvm/iOther.h" @@ -96,7 +96,7 @@ const Type *getStructOffsetType(const Type *Ty, unsigned &Offset, (i == SL->MemberOffsets.size()-1 || Offset <SL->MemberOffsets[i+1])); // Make sure to save the current index... - Offsets.push_back(ConstPoolUInt::get(Type::UByteTy, i)); + Offsets.push_back(ConstantUInt::get(Type::UByteTy, i)); ThisOffset = SL->MemberOffsets[i]; NextType = STy->getElementTypes()[i]; } else { @@ -106,7 +106,7 @@ const Type *getStructOffsetType(const Type *Ty, unsigned &Offset, NextType = ATy->getElementType(); unsigned ChildSize = TD.getTypeSize(NextType); - Offsets.push_back(ConstPoolUInt::get(Type::UIntTy, Offset/ChildSize)); + Offsets.push_back(ConstantUInt::get(Type::UIntTy, Offset/ChildSize)); ThisOffset = (Offset/ChildSize)*ChildSize; } @@ -183,7 +183,7 @@ const Type *ConvertableToGEP(const Type *Ty, Value *OffsetVal, if (Offset >= ElSize) { // Calculate the index that we are entering into the array cell with unsigned Index = Offset/ElSize; - Indices.push_back(ConstPoolUInt::get(Type::UIntTy, Index)); + Indices.push_bac |