forked from OSchip/llvm-project
[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
This commit is contained in:
parent
b15b5e9218
commit
5fe40050bd
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue