forked from OSchip/llvm-project
Fix recursive -only-needed.
We were assuming that only linkonce_odr GVs were lazy linked. llvm-svn: 266995
This commit is contained in:
parent
bf8b5f8dd2
commit
15ca14c0b9
|
@ -849,9 +849,11 @@ bool IRLinker::shouldLink(GlobalValue *DGV, GlobalValue &SGV) {
|
|||
if (SGV.hasAvailableExternallyLinkage())
|
||||
return true;
|
||||
|
||||
if (DoneLinkingBodies)
|
||||
if (SGV.isDeclaration())
|
||||
return false;
|
||||
|
||||
if (DoneLinkingBodies)
|
||||
return false;
|
||||
|
||||
// Callback to the client to give a chance to lazily add the Global to the
|
||||
// list of value to link.
|
||||
|
|
|
@ -423,7 +423,7 @@ void ModuleLinker::addLazyFor(GlobalValue &GV, IRMover::ValueAdder Add) {
|
|||
return;
|
||||
|
||||
// Add these to the internalize list
|
||||
if (!GV.hasLinkOnceLinkage())
|
||||
if (!GV.hasLinkOnceLinkage() && !shouldLinkOnlyNeeded())
|
||||
return;
|
||||
|
||||
if (shouldInternalizeLinkedSymbols())
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
define void @f2() {
|
||||
call void @f3()
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @f3() {
|
||||
ret void
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
; RUN: llvm-link -S -only-needed %s %p/Inputs/only-needed-recurse.ll | FileCheck %s
|
||||
|
||||
declare void @f2()
|
||||
|
||||
define void @f1() {
|
||||
call void @f2()
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: define void @f3
|
||||
|
Loading…
Reference in New Issue