mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-26 09:18:56 +00:00
Add CloneTraceInto(), which is based on (and has mostly the same
effects as) CloneFunctionInto(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13601 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -15,9 +15,11 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "llvm/Analysis/Trace.h"
|
||||||
#include "llvm/Transforms/Utils/Cloning.h"
|
#include "llvm/Transforms/Utils/Cloning.h"
|
||||||
#include "llvm/iPHINode.h"
|
#include "llvm/iPHINode.h"
|
||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
|
#include "ValueMapper.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
//Clones the trace (a vector of basic blocks)
|
//Clones the trace (a vector of basic blocks)
|
||||||
@@ -84,3 +86,34 @@ llvm::CloneTrace(const std::vector<BasicBlock*> &origTrace) {
|
|||||||
//return new vector of basic blocks
|
//return new vector of basic blocks
|
||||||
return clonedTrace;
|
return clonedTrace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// CloneTraceInto - Clone T into NewFunc. Original<->clone mapping is
|
||||||
|
/// saved in ValueMap.
|
||||||
|
///
|
||||||
|
void llvm::CloneTraceInto(Function *NewFunc, Trace &T,
|
||||||
|
std::map<const Value*, Value*> &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<BasicBlock>(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user