From 597ef105771dc7cac190fa67b7b28d34c6df0d5a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 27 Aug 2009 03:56:43 +0000 Subject: [PATCH] remove CloneTrace, which appears to be dead since 2004. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80201 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Utils/Cloning.h | 20 +--- lib/Transforms/Utils/CMakeLists.txt | 1 - lib/Transforms/Utils/CloneTrace.cpp | 119 ------------------------ 3 files changed, 3 insertions(+), 137 deletions(-) delete mode 100644 lib/Transforms/Utils/CloneTrace.cpp diff --git a/include/llvm/Transforms/Utils/Cloning.h b/include/llvm/Transforms/Utils/Cloning.h index 66cac9fea4b..869c446d78f 100644 --- a/include/llvm/Transforms/Utils/Cloning.h +++ b/include/llvm/Transforms/Utils/Cloning.h @@ -104,9 +104,9 @@ BasicBlock *CloneBasicBlock(const BasicBlock *BB, ClonedCodeInfo *CodeInfo = 0); -/// CloneLoop - Clone Loop. Clone dominator info for loop insiders. Populate ValueMap -/// using old blocks to new blocks mapping. -Loop *CloneLoop(Loop *L, LPPassManager *LPM, LoopInfo *LI, +/// CloneLoop - Clone Loop. Clone dominator info for loop insiders. Populate +/// ValueMap using old blocks to new blocks mapping. +Loop *CloneLoop(Loop *L, LPPassManager *LPM, LoopInfo *LI, DenseMap &ValueMap, Pass *P); /// CloneFunction - Return a copy of the specified function, but without @@ -155,20 +155,6 @@ void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, ClonedCodeInfo *CodeInfo = 0, const TargetData *TD = 0); - -/// CloneTraceInto - Clone T into NewFunc. Original<->clone mapping is -/// saved in ValueMap. -/// -void CloneTraceInto(Function *NewFunc, Trace &T, - DenseMap &ValueMap, - const char *NameSuffix); - -/// CloneTrace - Returns a copy of the specified trace. -/// It takes a vector of basic blocks clones the basic blocks, removes internal -/// phi nodes, adds it to the same function as the original (although there is -/// no jump to it) and returns the new vector of basic blocks. -std::vector CloneTrace(const std::vector &origTrace); - /// InlineFunction - This function inlines the called function into the basic /// block of the caller. This returns false if it is not possible to inline /// this call. The program is still in a well defined state if this occurs diff --git a/lib/Transforms/Utils/CMakeLists.txt b/lib/Transforms/Utils/CMakeLists.txt index e11aca164ef..aca4bca500b 100644 --- a/lib/Transforms/Utils/CMakeLists.txt +++ b/lib/Transforms/Utils/CMakeLists.txt @@ -6,7 +6,6 @@ add_llvm_library(LLVMTransformUtils CloneFunction.cpp CloneLoop.cpp CloneModule.cpp - CloneTrace.cpp CodeExtractor.cpp DemoteRegToStack.cpp InlineCost.cpp diff --git a/lib/Transforms/Utils/CloneTrace.cpp b/lib/Transforms/Utils/CloneTrace.cpp deleted file mode 100644 index 07111393e27..00000000000 --- a/lib/Transforms/Utils/CloneTrace.cpp +++ /dev/null @@ -1,119 +0,0 @@ -//===- CloneTrace.cpp - Clone a trace -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the CloneTrace interface, which is used when writing -// runtime optimizations. It takes a vector of basic blocks clones the basic -// blocks, removes internal phi nodes, adds it to the same function as the -// original (although there is no jump to it) and returns the new vector of -// basic blocks. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Analysis/Trace.h" -#include "llvm/Transforms/Utils/Cloning.h" -#include "llvm/Instructions.h" -#include "llvm/Function.h" -#include "llvm/Transforms/Utils/ValueMapper.h" -using namespace llvm; - -//Clones the trace (a vector of basic blocks) -std::vector -llvm::CloneTrace(const std::vector &origTrace) { - std::vector clonedTrace; - DenseMap ValueMap; - - //First, loop over all the Basic Blocks in the trace and copy - //them using CloneBasicBlock. Also fix the phi nodes during - //this loop. To fix the phi nodes, we delete incoming branches - //that are not in the trace. - for (std::vector::const_iterator T = origTrace.begin(), - End = origTrace.end(); T != End; ++T) { - - //Clone Basic Block - BasicBlock *clonedBlock = - CloneBasicBlock(*T, ValueMap, ".tr", (*T)->getParent()); - - //Add it to our new trace - clonedTrace.push_back(clonedBlock); - - //Add this new mapping to our Value Map - ValueMap[*T] = clonedBlock; - - //Loop over the phi instructions and delete operands - //that are from blocks not in the trace - //only do this if we are NOT the first block - if (T != origTrace.begin()) { - for (BasicBlock::iterator I = clonedBlock->begin(); - isa(I); ++I) { - PHINode *PN = cast(I); - //get incoming value for the previous BB - Value *V = PN->getIncomingValueForBlock(*(T-1)); - assert(V && "No incoming value from a BasicBlock in our trace!"); - - //remap our phi node to point to incoming value - ValueMap[*&I] = V; - - //remove phi node - clonedBlock->getInstList().erase(PN); - } - } - } - - //Second loop to do the remapping - for (std::vector::const_iterator BB = clonedTrace.begin(), - BE = clonedTrace.end(); BB != BE; ++BB) { - for (BasicBlock::iterator I = (*BB)->begin(); I != (*BB)->end(); ++I) { - //Loop over all the operands of the instruction - for (unsigned op=0, E = I->getNumOperands(); op != E; ++op) { - const Value *Op = I->getOperand(op); - - //Get it out of the value map - Value *V = ValueMap[Op]; - - //If not in the value map, then its outside our trace so ignore - if (V != 0) - I->setOperand(op,V); - } - } - } - - //return new vector of basic blocks - return clonedTrace; -} - -/// CloneTraceInto - Clone T into NewFunc. Original<->clone mapping is -/// saved in ValueMap. -/// -void llvm::CloneTraceInto(Function *NewFunc, Trace &T, - DenseMap &ValueMap, - const char *NameSuffix) { - assert(NameSuffix && "NameSuffix cannot be null!"); - - // Loop over all of the basic blocks in the trace, cloning them as - // appropriate. - // - for (Trace::const_iterator BI = T.begin(), BE = T.end(); BI != BE; ++BI) { - const BasicBlock *BB = *BI; - - // Create a new basic block and copy instructions into it! - BasicBlock *CBB = CloneBasicBlock(BB, ValueMap, NameSuffix, NewFunc); - ValueMap[BB] = CBB; // Add basic block mapping. - } - - // Loop over all of the instructions in the new function, fixing up operand - // references as we go. This uses ValueMap to do all the hard work. - // - for (Function::iterator BB = - cast(ValueMap[T.getEntryBasicBlock()]), - BE = NewFunc->end(); BB != BE; ++BB) - // Loop over all instructions, fixing each one as we find it... - for (BasicBlock::iterator II = BB->begin(); II != BB->end(); ++II) - RemapInstruction(II, ValueMap); -} -