diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-10-13 01:36:30 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-10-13 01:36:30 +0000 |
commit | 1ed219a9d2279ce5a5bbcf16d9b7ccc05cce638c (patch) | |
tree | cabdfe72018ddef0db2833e284ff6d33c3d4c5c9 | |
parent | 6932643a371b7a6dcc0c2b4f3a38b6b18759da87 (diff) | |
download | external_llvm-1ed219a9d2279ce5a5bbcf16d9b7ccc05cce638c.zip external_llvm-1ed219a9d2279ce5a5bbcf16d9b7ccc05cce638c.tar.gz external_llvm-1ed219a9d2279ce5a5bbcf16d9b7ccc05cce638c.tar.bz2 |
Be more consistent in using ValueToValueMapTy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116387 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Transforms/Utils/Cloning.h | 15 | ||||
-rw-r--r-- | lib/Transforms/IPO/PartialInlining.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/IPO/PartialSpecialization.cpp | 6 | ||||
-rw-r--r-- | lib/Transforms/Scalar/LoopUnswitch.cpp | 10 | ||||
-rw-r--r-- | lib/Transforms/Utils/CloneLoop.cpp | 12 | ||||
-rw-r--r-- | lib/Transforms/Utils/InlineFunction.cpp | 6 | ||||
-rw-r--r-- | lib/Transforms/Utils/LoopUnroll.cpp | 7 | ||||
-rw-r--r-- | tools/bugpoint/BugDriver.h | 3 | ||||
-rw-r--r-- | tools/bugpoint/CrashDebugger.cpp | 8 | ||||
-rw-r--r-- | tools/bugpoint/ExtractFunction.cpp | 6 | ||||
-rw-r--r-- | tools/bugpoint/Miscompilation.cpp | 12 |
11 files changed, 44 insertions, 43 deletions
diff --git a/include/llvm/Transforms/Utils/Cloning.h b/include/llvm/Transforms/Utils/Cloning.h index 62bf92a..24ebb10 100644 --- a/include/llvm/Transforms/Utils/Cloning.h +++ b/include/llvm/Transforms/Utils/Cloning.h @@ -22,6 +22,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/ValueHandle.h" +#include "llvm/Transforms/Utils/ValueMapper.h" namespace llvm { @@ -46,7 +47,7 @@ class AllocaInst; /// CloneModule - Return an exact copy of the specified module /// Module *CloneModule(const Module *M); -Module *CloneModule(const Module *M, ValueMap<const Value*, Value*> &VMap); +Module *CloneModule(const Module *M, ValueToValueMapTy &VMap); /// ClonedCodeInfo - This struct can be used to capture information about code /// being cloned, while it is being cloned. @@ -102,7 +103,7 @@ struct ClonedCodeInfo { /// parameter. /// BasicBlock *CloneBasicBlock(const BasicBlock *BB, - ValueMap<const Value*, Value*> &VMap, + ValueToValueMapTy &VMap, const Twine &NameSuffix = "", Function *F = 0, ClonedCodeInfo *CodeInfo = 0); @@ -110,7 +111,7 @@ BasicBlock *CloneBasicBlock(const BasicBlock *BB, /// CloneLoop - Clone Loop. Clone dominator info for loop insiders. Populate /// VMap using old blocks to new blocks mapping. Loop *CloneLoop(Loop *L, LPPassManager *LPM, LoopInfo *LI, - ValueMap<const Value *, Value *> &VMap, Pass *P); + ValueToValueMapTy &VMap, Pass *P); /// CloneFunction - Return a copy of the specified function, but without /// embedding the function into another module. Also, any references specified @@ -125,14 +126,14 @@ Loop *CloneLoop(Loop *L, LPPassManager *LPM, LoopInfo *LI, /// mappings. /// Function *CloneFunction(const Function *F, - ValueMap<const Value*, Value*> &VMap, + ValueToValueMapTy &VMap, bool ModuleLevelChanges, ClonedCodeInfo *CodeInfo = 0); /// CloneFunction - Version of the function that doesn't need the VMap. /// inline Function *CloneFunction(const Function *F, ClonedCodeInfo *CodeInfo = 0){ - ValueMap<const Value*, Value*> VMap; + ValueToValueMapTy VMap; return CloneFunction(F, VMap, CodeInfo); } @@ -146,7 +147,7 @@ inline Function *CloneFunction(const Function *F, ClonedCodeInfo *CodeInfo = 0){ /// mappings. /// void CloneFunctionInto(Function *NewFunc, const Function *OldFunc, - ValueMap<const Value*, Value*> &VMap, + ValueToValueMapTy &VMap, bool ModuleLevelChanges, SmallVectorImpl<ReturnInst*> &Returns, const char *NameSuffix = "", @@ -164,7 +165,7 @@ void CloneFunctionInto(Function *NewFunc, const Function *OldFunc, /// mappings. /// void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, - ValueMap<const Value*, Value*> &VMap, + ValueToValueMapTy &VMap, bool ModuleLevelChanges, SmallVectorImpl<ReturnInst*> &Returns, const char *NameSuffix = "", diff --git a/lib/Transforms/IPO/PartialInlining.cpp b/lib/Transforms/IPO/PartialInlining.cpp index c0c252f..326285a 100644 --- a/lib/Transforms/IPO/PartialInlining.cpp +++ b/lib/Transforms/IPO/PartialInlining.cpp @@ -67,7 +67,7 @@ Function* PartialInliner::unswitchFunction(Function* F) { return 0; // Clone the function, so that we can hack away on it. - ValueMap<const Value*, Value*> VMap; + ValueToValueMapTy VMap; Function* duplicateFunction = CloneFunction(F, VMap, /*ModuleLevelChanges=*/false); duplicateFunction->setLinkage(GlobalValue::InternalLinkage); diff --git a/lib/Transforms/IPO/PartialSpecialization.cpp b/lib/Transforms/IPO/PartialSpecialization.cpp index 037189e..d3222ba 100644 --- a/lib/Transforms/IPO/PartialSpecialization.cpp +++ b/lib/Transforms/IPO/PartialSpecialization.cpp @@ -60,10 +60,10 @@ INITIALIZE_PASS(PartSpec, "partialspecialization", // a call to the specialized function. Returns the specialized function static Function* SpecializeFunction(Function* F, - ValueMap<const Value*, Value*>& replacements) { + ValueToValueMapTy& replacements) { // arg numbers of deleted arguments DenseMap<unsigned, const Argument*> deleted; - for (ValueMap<const Value*, Value*>::iterator + for (ValueToValueMapTy::iterator repb = replacements.begin(), repe = replacements.end(); repb != repe; ++repb) { Argument const *arg = cast<const Argument>(repb->first); @@ -164,7 +164,7 @@ bool PartSpec::runOnModule(Module &M) { // leave the original function dead and removable. if (cost.isAlways() || (cost.isVariable() && cost.getValue() < bonus)) { - ValueMap<const Value*, Value*> m; + ValueToValueMapTy m; Function::arg_iterator arg = F.arg_begin(); for (int y = 0; y < interestingArgs[x]; ++y) ++arg; diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index 7eed454..6f3a15b 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -461,10 +461,10 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val) { // current values into those specified by VMap. // static inline void RemapInstruction(Instruction *I, - ValueMap<const Value *, Value*> &VMap) { + ValueToValueMapTy &VMap) { for (unsigned op = 0, E = I->getNumOperands(); op != E; ++op) { Value *Op = I->getOperand(op); - ValueMap<const Value *, Value*>::iterator It = VMap.find(Op); + ValueToValueMapTy::iterator It = VMap.find(Op); if (It != VMap.end()) Op = It->second; I->setOperand(op, Op); } @@ -472,7 +472,7 @@ static inline void RemapInstruction(Instruction *I, /// CloneLoop - Recursively clone the specified loop and all of its children, /// mapping the blocks with the specified map. -static Loop *CloneLoop(Loop *L, Loop *PL, ValueMap<const Value*, Value*> &VM, +static Loop *CloneLoop(Loop *L, Loop *PL, ValueToValueMapTy &VM, LoopInfo *LI, LPPassManager *LPM) { Loop *New = new Loop(); LPM->insertLoop(New, PL); @@ -616,7 +616,7 @@ void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val, // the loop preheader and exit blocks), keeping track of the mapping between // the instructions and blocks. NewBlocks.reserve(LoopBlocks.size()); - ValueMap<const Value*, Value*> VMap; + ValueToValueMapTy VMap; for (unsigned i = 0, e = LoopBlocks.size(); i != e; ++i) { BasicBlock *NewBB = CloneBasicBlock(LoopBlocks[i], VMap, ".us", F); NewBlocks.push_back(NewBB); @@ -654,7 +654,7 @@ void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val, for (BasicBlock::iterator I = ExitSucc->begin(); isa<PHINode>(I); ++I) { PN = cast<PHINode>(I); Value *V = PN->getIncomingValueForBlock(ExitBlocks[i]); - ValueMap<const Value *, Value*>::iterator It = VMap.find(V); + ValueToValueMapTy::iterator It = VMap.find(V); if (It != VMap.end()) V = It->second; PN->addIncoming(V, NewExit); } diff --git a/lib/Transforms/Utils/CloneLoop.cpp b/lib/Transforms/Utils/CloneLoop.cpp index 551b630..ba8f3d5 100644 --- a/lib/Transforms/Utils/CloneLoop.cpp +++ b/lib/Transforms/Utils/CloneLoop.cpp @@ -22,12 +22,12 @@ using namespace llvm; /// CloneDominatorInfo - Clone basicblock's dominator tree and, if available, /// dominance info. It is expected that basic block is already cloned. static void CloneDominatorInfo(BasicBlock *BB, - ValueMap<const Value *, Value *> &VMap, + ValueToValueMapTy &VMap, DominatorTree *DT, DominanceFrontier *DF) { assert (DT && "DominatorTree is not available"); - ValueMap<const Value *, Value*>::iterator BI = VMap.find(BB); + ValueToValueMapTy::iterator BI = VMap.find(BB); assert (BI != VMap.end() && "BasicBlock clone is missing"); BasicBlock *NewBB = cast<BasicBlock>(BI->second); @@ -42,7 +42,7 @@ static void CloneDominatorInfo(BasicBlock *BB, // NewBB's dominator is either BB's dominator or BB's dominator's clone. BasicBlock *NewBBDom = BBDom; - ValueMap<const Value *, Value*>::iterator BBDomI = VMap.find(BBDom); + ValueToValueMapTy::iterator BBDomI = VMap.find(BBDom); if (BBDomI != VMap.end()) { NewBBDom = cast<BasicBlock>(BBDomI->second); if (!DT->getNode(NewBBDom)) @@ -59,7 +59,7 @@ static void CloneDominatorInfo(BasicBlock *BB, for (DominanceFrontier::DomSetType::iterator I = S.begin(), E = S.end(); I != E; ++I) { BasicBlock *DB = *I; - ValueMap<const Value*, Value*>::iterator IDM = VMap.find(DB); + ValueToValueMapTy::iterator IDM = VMap.find(DB); if (IDM != VMap.end()) NewDFSet.insert(cast<BasicBlock>(IDM->second)); else @@ -73,7 +73,7 @@ static void CloneDominatorInfo(BasicBlock *BB, /// CloneLoop - Clone Loop. Clone dominator info. Populate VMap /// using old blocks to new blocks mapping. Loop *llvm::CloneLoop(Loop *OrigL, LPPassManager *LPM, LoopInfo *LI, - ValueMap<const Value *, Value *> &VMap, Pass *P) { + ValueToValueMapTy &VMap, Pass *P) { DominatorTree *DT = NULL; DominanceFrontier *DF = NULL; @@ -134,7 +134,7 @@ Loop *llvm::CloneLoop(Loop *OrigL, LPPassManager *LPM, LoopInfo *LI, for (unsigned index = 0, num_ops = Insn->getNumOperands(); index != num_ops; ++index) { Value *Op = Insn->getOperand(index); - ValueMap<const Value *, Value *>::iterator OpItr = VMap.find(Op); + ValueToValueMapTy::iterator OpItr = VMap.find(Op); if (OpItr != VMap.end()) Insn->setOperand(index, OpItr->second); } diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 88979e8..e09666a 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -170,7 +170,7 @@ static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock, /// some edges of the callgraph may remain. static void UpdateCallGraphAfterInlining(CallSite CS, Function::iterator FirstNewBlock, - ValueMap<const Value*, Value*> &VMap, + ValueToValueMapTy &VMap, InlineFunctionInfo &IFI) { CallGraph &CG = *IFI.CG; const Function *Caller = CS.getInstruction()->getParent()->getParent(); @@ -193,7 +193,7 @@ static void UpdateCallGraphAfterInlining(CallSite CS, for (; I != E; ++I) { const Value *OrigCall = I->first; - ValueMap<const Value*, Value*>::iterator VMI = VMap.find(OrigCall); + ValueToValueMapTy::iterator VMI = VMap.find(OrigCall); // Only copy the edge if the call was inlined! if (VMI == VMap.end() || VMI->second == 0) continue; @@ -287,7 +287,7 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI) { Function::iterator FirstNewBlock; { // Scope to destroy VMap after cloning. - ValueMap<const Value*, Value*> VMap; + ValueToValueMapTy VMap; assert(CalledFunc->arg_size() == CS.arg_size() && "No varargs calls can be inlined!"); diff --git a/lib/Transforms/Utils/LoopUnroll.cpp b/lib/Transforms/Utils/LoopUnroll.cpp index 236bbe9..e23cdc9 100644 --- a/lib/Transforms/Utils/LoopUnroll.cpp +++ b/lib/Transforms/Utils/LoopUnroll.cpp @@ -40,10 +40,10 @@ STATISTIC(NumUnrolled, "Number of loops unrolled (completely or otherwise)"); /// RemapInstruction - Convert the instruction operands from referencing the /// current values into those specified by VMap. static inline void RemapInstruction(Instruction *I, - ValueMap<const Value *, Value*> &VMap) { + ValueToValueMapTy &VMap) { for (unsigned op = 0, E = I->getNumOperands(); op != E; ++op) { Value *Op = I->getOperand(op); - ValueMap<const Value *, Value*>::iterator It = VMap.find(Op); + ValueToValueMapTy::iterator It = VMap.find(Op); if (It != VMap.end()) I->setOperand(op, It->second); } @@ -189,7 +189,6 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, LoopInfo* LI, LPPassManager* LPM) // For the first iteration of the loop, we should use the precloned values for // PHI nodes. Insert associations now. - typedef ValueMap<const Value*, Value*> ValueToValueMapTy; ValueToValueMapTy LastValueMap; std::vector<PHINode*> OrigPHINode; for (BasicBlock::iterator I = Header->begin(); isa<PHINode>(I); ++I) { @@ -274,7 +273,7 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, LoopInfo* LI, LPPassManager* LPM) for (unsigned i = 0; i < NewBlocks.size(); ++i) for (BasicBlock::iterator I = NewBlocks[i]->begin(), E = NewBlocks[i]->end(); I != E; ++I) - RemapInstruction(I, LastValueMap); + ::RemapInstruction(I, LastValueMap); } // The latch block exits the loop. If there are any PHI nodes in the diff --git a/tools/bugpoint/BugDriver.h b/tools/bugpoint/BugDriver.h index e48806a..cc78489 100644 --- a/tools/bugpoint/BugDriver.h +++ b/tools/bugpoint/BugDriver.h @@ -17,6 +17,7 @@ #define BUGDRIVER_H #include "llvm/ADT/ValueMap.h" +#include "llvm/Transforms/Utils/ValueMapper.h" #include <vector> #include <string> @@ -322,7 +323,7 @@ void DeleteFunctionBody(Function *F); /// module, split the functions OUT of the specified module, and place them in /// the new module. Module *SplitFunctionsOutOfModule(Module *M, const std::vector<Function*> &F, - ValueMap<const Value*, Value*> &VMap); + ValueToValueMapTy &VMap); } // End llvm namespace diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp index 57dc1c8..f19ef62 100644 --- a/tools/bugpoint/CrashDebugger.cpp +++ b/tools/bugpoint/CrashDebugger.cpp @@ -130,7 +130,7 @@ bool ReduceCrashingGlobalVariables::TestGlobalVariables( std::vector<GlobalVariable*> &GVs) { // Clone the program to try hacking it apart... - ValueMap<const Value*, Value*> VMap; + ValueToValueMapTy VMap; Module *M = CloneModule(BD.getProgram(), VMap); // Convert list to set for fast lookup... @@ -204,7 +204,7 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) { return false; // Clone the program to try hacking it apart... - ValueMap<const Value*, Value*> VMap; + ValueToValueMapTy VMap; Module *M = CloneModule(BD.getProgram(), VMap); // Convert list to set for fast lookup... @@ -271,7 +271,7 @@ namespace { bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) { // Clone the program to try hacking it apart... - ValueMap<const Value*, Value*> VMap; + ValueToValueMapTy VMap; Module *M = CloneModule(BD.getProgram(), VMap); // Convert list to set for fast lookup... @@ -381,7 +381,7 @@ namespace { bool ReduceCrashingInstructions::TestInsts(std::vector<const Instruction*> &Insts) { // Clone the program to try hacking it apart... - ValueMap<const Value*, Value*> VMap; + ValueToValueMapTy VMap; Module *M = CloneModule(BD.getProgram(), VMap); // Convert list to set for fast lookup... diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp index b7d5f9f..4be16bc 100644 --- a/tools/bugpoint/ExtractFunction.cpp +++ b/tools/bugpoint/ExtractFunction.cpp @@ -193,7 +193,7 @@ static Constant *GetTorInit(std::vector<std::pair<Function*, int> > &TorList) { /// static ctors/dtors, we need to add an llvm.global_[cd]tors global to M2, and /// prune appropriate entries out of M1s list. static void SplitStaticCtorDtor(const char *GlobalName, Module *M1, Module *M2, - ValueMap<const Value*, Value*> &VMap) { + ValueToValueMapTy &VMap) { GlobalVariable *GV = M1->getNamedGlobal(GlobalName); if (!GV || GV->isDeclaration() || GV->hasLocalLinkage() || !GV->use_empty()) return; @@ -256,7 +256,7 @@ static void SplitStaticCtorDtor(const char *GlobalName, Module *M1, Module *M2, Module * llvm::SplitFunctionsOutOfModule(Module *M, const std::vector<Function*> &F, - ValueMap<const Value*, Value*> &VMap) { + ValueToValueMapTy &VMap) { // Make sure functions & globals are all external so that linkage // between the two modules will work. for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) @@ -268,7 +268,7 @@ llvm::SplitFunctionsOutOfModule(Module *M, I->setLinkage(GlobalValue::ExternalLinkage); } - ValueMap<const Value*, Value*> NewVMap; + ValueToValueMapTy NewVMap; Module *New = CloneModule(M, NewVMap); // Make sure global initializers exist only in the safe module (CBE->.so) diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp index 3f2b696..3a5f143 100644 --- a/tools/bugpoint/Miscompilation.cpp +++ b/tools/bugpoint/Miscompilation.cpp @@ -261,7 +261,7 @@ bool ReduceMiscompilingFunctions::TestFuncs(const std::vector<Function*> &Funcs, // a function, we want to continue with the original function. Otherwise // we can conclude that a function triggers the bug when in fact one // needs a larger set of original functions to do so. - ValueMap<const Value*, Value*> VMap; + ValueToValueMapTy VMap; Module *Clone = CloneModule(BD.getProgram(), VMap); Module *Orig = BD.swapProgramIn(Clone); @@ -310,7 +310,7 @@ static bool ExtractLoops(BugDriver &BD, while (1) { if (BugpointIsInterrupted) return MadeChange; - ValueMap<const Value*, Value*> VMap; + ValueToValueMapTy VMap; Module *ToNotOptimize = CloneModule(BD.getProgram(), VMap); Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize, MiscompiledFunctions, @@ -476,7 +476,7 @@ bool ReduceMiscompiledBlocks::TestFuncs(const std::vector<BasicBlock*> &BBs, outs() << '\n'; // Split the module into the two halves of the program we want. - ValueMap<const Value*, Value*> VMap; + ValueToValueMapTy VMap; Module *Clone = CloneModule(BD.getProgram(), VMap); Module *Orig = BD.swapProgramIn(Clone); std::vector<Function*> FuncsOnClone; @@ -551,7 +551,7 @@ static bool ExtractBlocks(BugDriver &BD, return false; } - ValueMap<const Value*, Value*> VMap; + ValueToValueMapTy VMap; Module *ProgClone = CloneModule(BD.getProgram(), VMap); Module *ToExtract = SplitFunctionsOutOfModule(ProgClone, MiscompiledFunctions, @@ -738,7 +738,7 @@ void BugDriver::debugMiscompilation(std::string *Error) { // Output a bunch of bitcode files for the user... outs() << "Outputting reduced bitcode files which expose the problem:\n"; - ValueMap<const Value*, Value*> VMap; + ValueToValueMapTy VMap; Module *ToNotOptimize = CloneModule(getProgram(), VMap); Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize, MiscompiledFunctions, @@ -1011,7 +1011,7 @@ bool BugDriver::debugCodeGenerator(std::string *Error) { return true; // Split the module into the two halves of the program we want. - ValueMap<const Value*, Value*> VMap; + ValueToValueMapTy VMap; Module *ToNotCodeGen = CloneModule(getProgram(), VMap); Module *ToCodeGen = SplitFunctionsOutOfModule(ToNotCodeGen, Funcs, VMap); |