[PATCH] D14474: Also map the personality function in CloneFunctionInto

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 15 21:16:15 PST 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL253183: Also map the personality function in CloneFunctionInto (authored by kfischer).

Changed prior to commit:
  http://reviews.llvm.org/D14474?vs=39620&id=40246#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14474

Files:
  llvm/trunk/lib/IR/Verifier.cpp
  llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp

Index: llvm/trunk/lib/IR/Verifier.cpp
===================================================================
--- llvm/trunk/lib/IR/Verifier.cpp
+++ llvm/trunk/lib/IR/Verifier.cpp
@@ -1715,6 +1715,14 @@
   assert(F.hasMetadata() != MDs.empty() && "Bit out-of-sync");
   VerifyFunctionMetadata(MDs);
 
+  // Check validity of the personality function
+  if (F.hasPersonalityFn()) {
+    auto *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,
Index: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp
+++ llvm/trunk/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 (OldFunc->hasPersonalityFn())
+    NewFunc->setPersonalityFn(
+        MapValue(OldFunc->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())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14474.40246.patch
Type: text/x-patch
Size: 1570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151116/8aad6657/attachment.bin>


More information about the llvm-commits mailing list