diff options
author | Teresa Johnson <tejohnson@google.com> | 2016-01-12 00:24:24 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2016-01-12 00:24:24 +0000 |
commit | 5fe40050bda3eeff49145ce34a5ea85b8880b54e (patch) | |
tree | 69a70fcb57b582297838b67b1a1d91e5b59d1ebf /llvm/lib/Linker/IRMover.cpp | |
parent | b15b5e92189aaff65e726f610dedb9f4e95ebeae (diff) | |
download | bcm5719-llvm-5fe40050bda3eeff49145ce34a5ea85b8880b54e.tar.gz bcm5719-llvm-5fe40050bda3eeff49145ce34a5ea85b8880b54e.zip |
[IRMover] Don't copy personality, etc unless creating def
Function::copyAttributesFrom will copy the personality function, prefix
data and prolog data from the source function to the new function, and
is invoked when the IRMover copies the function prototype. This puts a
reference to a constant in the source module on a function in the dest
module, which causes an error when deleting the source module after
importing, since the personality function in the source module still has
uses (this would presumably also be an issue for the prologue and prefix
data). Remove the copies added to the dest copy when creating the new
prototype, as they are mapped properly when/if we link the function body.
llvm-svn: 257420
Diffstat (limited to 'llvm/lib/Linker/IRMover.cpp')
-rw-r--r-- | llvm/lib/Linker/IRMover.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index 16de0ec88f4..8dd59f9e0e3 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -773,6 +773,16 @@ GlobalValue *IRLinker::copyGlobalValueProto(const GlobalValue *SGV, NewGV->setLinkage(GlobalValue::ExternalWeakLinkage); NewGV->copyAttributesFrom(SGV); + + // Remove these copied constants in case this stays a declaration, since + // they point to the source module. If the def is linked the values will + // be mapped in during linkFunctionBody. + if (auto *NewF = dyn_cast<Function>(NewGV)) { + NewF->setPersonalityFn(nullptr); + NewF->setPrefixData(nullptr); + NewF->setPrologueData(nullptr); + } + return NewGV; } |