diff options
| -rw-r--r-- | llvm/lib/Linker/IRMover.cpp | 10 | ||||
| -rw-r--r-- | llvm/test/Transforms/FunctionImport/Inputs/funcimport.ll | 15 | ||||
| -rw-r--r-- | llvm/test/Transforms/FunctionImport/funcimport.ll | 2 |
3 files changed, 27 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; } diff --git a/llvm/test/Transforms/FunctionImport/Inputs/funcimport.ll b/llvm/test/Transforms/FunctionImport/Inputs/funcimport.ll index 96555892fe3..79b766b386d 100644 --- a/llvm/test/Transforms/FunctionImport/Inputs/funcimport.ll +++ b/llvm/test/Transforms/FunctionImport/Inputs/funcimport.ll @@ -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 diff --git a/llvm/test/Transforms/FunctionImport/funcimport.ll b/llvm/test/Transforms/FunctionImport/funcimport.ll index c099b976647..52fd53d3f31 100644 --- a/llvm/test/Transforms/FunctionImport/funcimport.ll +++ b/llvm/test/Transforms/FunctionImport/funcimport.ll @@ -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() |

