[PATCH] D14474: Also map the personality function in CloneFunctionInto
Keno Fischer via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 6 18:26:11 PST 2015
loladiro created this revision.
loladiro added a reviewer: majnemer.
loladiro added a subscriber: llvm-commits.
loladiro set the repository for this revision to rL LLVM.
The Old personality function gets copied over, but the Materializer didn't have a chance to inspect it (e.g. to fix up references to the correct module for the target function). Also add a verifier check that makes sure the personality routine is in the same module as the function whose personality it is.
Repository:
rL LLVM
http://reviews.llvm.org/D14474
Files:
lib/IR/Verifier.cpp
lib/Transforms/Utils/CloneFunction.cpp
Index: lib/Transforms/Utils/CloneFunction.cpp
===================================================================
--- lib/Transforms/Utils/CloneFunction.cpp
+++ lib/Transforms/Utils/CloneFunction.cpp
@@ -95,6 +95,13 @@
NewFunc->copyAttributesFrom(OldFunc);
NewFunc->setAttributes(NewAttrs);
+ // Fix up the personality function that got copied over
+ if (NewFunc->hasPersonalityFn())
+ NewFunc->setPersonalityFn(
+ MapValue(NewFunc->getPersonalityFn(), VMap,
+ ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges,
+ TypeMapper, Materializer));
+
AttributeSet OldAttrs = OldFunc->getAttributes();
// Clone any argument attributes that are present in the VMap.
for (const Argument &OldArg : OldFunc->args())
Index: lib/IR/Verifier.cpp
===================================================================
--- lib/IR/Verifier.cpp
+++ lib/IR/Verifier.cpp
@@ -1757,6 +1757,15 @@
assert(F.hasMetadata() != MDs.empty() && "Bit out-of-sync");
VerifyFunctionMetadata(MDs);
+ // Check validity of the personality function
+ if (F.hasPersonalityFn()) {
+ Function *Per =
+ dyn_cast<Function>(F->getPersonalityFn()->stripPointerCasts());
+ if (Per)
+ Assert(Per->getParent() == F.getParent(),
+ "Referencing personality function in another module!", &F, Per);
+ }
+
if (F.isMaterializable()) {
// Function has a body somewhere we can't see.
Assert(MDs.empty(), "unmaterialized function cannot have metadata", &F,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14474.39618.patch
Type: text/x-patch
Size: 1517 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151107/29e1be8e/attachment.bin>
More information about the llvm-commits
mailing list