[llvm] r257420 - [IRMover] Don't copy personality, etc unless creating def
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 11 16:24:25 PST 2016
Author: tejohnson
Date: Mon Jan 11 18:24:24 2016
New Revision: 257420
URL: http://llvm.org/viewvc/llvm-project?rev=257420&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/Linker/IRMover.cpp
llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport.ll
llvm/trunk/test/Transforms/FunctionImport/funcimport.ll
Modified: llvm/trunk/lib/Linker/IRMover.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/IRMover.cpp?rev=257420&r1=257419&r2=257420&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/IRMover.cpp (original)
+++ llvm/trunk/lib/Linker/IRMover.cpp Mon Jan 11 18:24:24 2016
@@ -773,6 +773,16 @@ GlobalValue *IRLinker::copyGlobalValuePr
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;
}
Modified: llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport.ll?rev=257420&r1=257419&r2=257420&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport.ll (original)
+++ llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport.ll Mon Jan 11 18:24:24 2016
@@ -10,6 +10,7 @@
define void @globalfunc1() #0 {
entry:
+ call void @funcwithpersonality()
ret void
}
@@ -79,6 +80,20 @@ entry:
ret i32 1
}
+declare i32 @__gxx_personality_v0(...)
+
+; Add enough instructions to prevent import with inst limit of 5
+define internal void @funcwithpersonality() #2 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+entry:
+ call void @globalfunc2()
+ call void @globalfunc2()
+ call void @globalfunc2()
+ call void @globalfunc2()
+ call void @globalfunc2()
+ call void @globalfunc2()
+ ret void
+}
+
define internal void @staticfunc2() #0 {
entry:
ret void
Modified: llvm/trunk/test/Transforms/FunctionImport/funcimport.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionImport/funcimport.ll?rev=257420&r1=257419&r2=257420&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/FunctionImport/funcimport.ll (original)
+++ llvm/trunk/test/Transforms/FunctionImport/funcimport.ll Mon Jan 11 18:24:24 2016
@@ -73,3 +73,5 @@ declare void @callfuncptr(...) #1
; CHECK-DAG: declare void @weakfunc(...)
declare void @weakfunc(...) #1
+; INSTLIMDEF-DAG: define available_externally hidden void @funcwithpersonality.llvm.2() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+; INSTLIM5-DAG: declare hidden void @funcwithpersonality.llvm.2()
More information about the llvm-commits
mailing list