aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/CloneFunction.cpp
diff options
context:
space:
mode:
authorAndrew Kaylor <andrew.kaylor@intel.com>2015-02-23 20:01:56 +0000
committerAndrew Kaylor <andrew.kaylor@intel.com>2015-02-23 20:01:56 +0000
commitf22fe4ae18ceef69a0c54286fdfe626ee80099f9 (patch)
treea5e004ac6a7cb0046ea4a9a46948019ca291b085 /llvm/lib/Transforms/Utils/CloneFunction.cpp
parent32173cdf06a92408a8e1cc3ad7b582fe7cc46c6a (diff)
downloadllvm-f22fe4ae18ceef69a0c54286fdfe626ee80099f9.zip
llvm-f22fe4ae18ceef69a0c54286fdfe626ee80099f9.tar.gz
llvm-f22fe4ae18ceef69a0c54286fdfe626ee80099f9.tar.bz2
Remap frame variables for native Windows exception handling.
Differential Revision: http://reviews.llvm.org/D7770 llvm-svn: 230249
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneFunction.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/CloneFunction.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index 40061ab..09279b6 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -261,6 +261,8 @@ namespace {
ClonedCodeInfo *CodeInfo;
const DataLayout *DL;
CloningDirector *Director;
+ ValueMapTypeRemapper *TypeMapper;
+ ValueMaterializer *Materializer;
public:
PruningFunctionCloner(Function *newFunc, const Function *oldFunc,
@@ -274,6 +276,14 @@ namespace {
VMap(valueMap), ModuleLevelChanges(moduleLevelChanges),
NameSuffix(nameSuffix), CodeInfo(codeInfo), DL(DL),
Director(Director) {
+ // These are optional components. The Director may return null.
+ if (Director) {
+ TypeMapper = Director->getTypeRemapper();
+ Materializer = Director->getValueMaterializer();
+ } else {
+ TypeMapper = nullptr;
+ Materializer = nullptr;
+ }
}
/// CloneBlock - The specified block is found to be reachable, clone it and
@@ -344,7 +354,8 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB,
// nodes for which we defer processing until we update the CFG.
if (!isa<PHINode>(NewInst)) {
RemapInstruction(NewInst, VMap,
- ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges);
+ ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges,
+ TypeMapper, Materializer);
// If we can simplify this instruction to some other value, simply add
// a mapping to that value rather than inserting a new instruction into
@@ -459,6 +470,14 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc,
CloningDirector *Director) {
assert(NameSuffix && "NameSuffix cannot be null!");
+ ValueMapTypeRemapper *TypeMapper = nullptr;
+ ValueMaterializer *Materializer = nullptr;
+
+ if (Director) {
+ TypeMapper = Director->getTypeRemapper();
+ Materializer = Director->getValueMaterializer();
+ }
+
#ifndef NDEBUG
// If the cloning starts at the begining of the function, verify that
// the function arguments are mapped.
@@ -513,7 +532,8 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc,
// Finally, remap the terminator instructions, as those can't be remapped
// until all BBs are mapped.
RemapInstruction(NewBB->getTerminator(), VMap,
- ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges);
+ ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges,
+ TypeMapper, Materializer);
}
// Defer PHI resolution until rest of function is resolved, PHI resolution