Link declaration lazily.

We already linked available_externally and linkonce lazily, this just
adds declarations to the list.

llvm-svn: 254917
This commit is contained in:
Rafael Espindola 2015-12-07 16:31:41 +00:00
parent 3c9d3f75b7
commit bd03c50336
14 changed files with 64 additions and 6 deletions

View File

@ -1753,6 +1753,9 @@ bool ModuleLinker::linkIfNeeded(GlobalValue &GV) {
GV.hasAvailableExternallyLinkage()))
return false;
if (GV.isDeclaration())
return false;
if (const Comdat *SC = GV.getComdat()) {
bool LinkFromSrc;
Comdat::SelectionKind SK;

View File

@ -4,3 +4,7 @@
declare void @foo()
define void @use_foo() {
call void @foo()
ret void
}

View File

@ -6,13 +6,13 @@
; CHECK-NEXT: ret i32 7
; CHECK-NEXT: }
; CHECK: declare i32 @foo()
; CHECK: define i32 @test() {
; CHECK-NEXT: %X = call i32 @foo()
; CHECK-NEXT: ret i32 %X
; CHECK-NEXT: }
; CHECK: declare i32 @foo()
declare i32 @foo()
define i32 @test() {

View File

@ -6,3 +6,7 @@
; CHECK-DAG: @Y = external global [1 x i32]
@Y = external global [1 x i32]
define [1 x i32]* @use-Y() {
ret [1 x i32] *@Y
}

View File

@ -11,3 +11,11 @@ define void @f1() {
getelementptr %A, %A* null, i32 0
ret void
}
define %A* @use_g2() {
ret %A* @g2
}
define %B* @use_g3() {
ret %B* @g3
}

View File

@ -53,4 +53,6 @@ define internal void @testIntern() {
ret void
}
declare void @VecSizeCrash1(%VecSize)
define void @VecSizeCrash1(%VecSize) {
ret void
}

View File

@ -1,3 +1,7 @@
%A.11 = type { %B }
%B = type { i8 }
@g1 = external global %A.11
define %A.11* @use_g1() {
ret %A.11* @g1
}

View File

@ -1,2 +1,6 @@
%A.11 = type opaque
@g2 = external global %A.11
define %A.11* @use_g2() {
ret %A.11* @g2
}

View File

@ -19,3 +19,7 @@
%C = type { %A }
@g1 = external global %B
define %B* @use_g1() {
ret %B* @g1
}

View File

@ -32,6 +32,11 @@
; CHECK-DAG: @0 = external global i32
@0 = external global i32
define i32* @use0() {
ret i32* @0
}
; CHECK-DAG: @Inte = global i32 1
@Inte = global i32 1
@ -101,4 +106,6 @@ define void @testIntern() {
ret void
}
declare void @VecSizeCrash(%VecSize)
define void @VecSizeCrash(%VecSize) {
ret void
}

View File

@ -17,3 +17,7 @@
%A = type { %B }
%B = type { i8 }
@g3 = external global %A
define %A* @use_g3() {
ret %A* @g3
}

View File

@ -10,7 +10,7 @@
; CHECK-NEXT: %B = type { %A }
; CHECK-NEXT: %A = type { i8 }
; CHECK: @g1 = external global %C.0
; CHECK: @g1 = global %C.0 zeroinitializer
; CHECK: getelementptr %C.0, %C.0* null, i64 0, i32 0, i32 0
%A = type { i8 }
@ -21,4 +21,4 @@ define void @f1() {
getelementptr %C, %C* null, i64 0, i32 0, i32 0
ret void
}
@g1 = external global %C.0
@g1 = global %C.0 zeroinitializer

View File

@ -15,6 +15,11 @@ define weak void @func-b() unnamed_addr { ret void }
@global-c = common unnamed_addr global i32 0
; CHECK-DAG: @global-c = common unnamed_addr global i32 0
@global-d = external global i32
define i32* @use-global-d() {
ret i32* @global-d
}
; CHECK-DAG: @global-d = global i32 42
@global-e = external unnamed_addr global i32
; CHECK-DAG: @global-e = unnamed_addr global i32 42
@ -27,6 +32,11 @@ define weak void @func-b() unnamed_addr { ret void }
; CHECK-DAG: @alias-b = unnamed_addr alias i32, i32* @global-f
declare void @func-c()
define void @use-func-c() {
call void @func-c()
ret void
}
; CHECK-DAG: define weak void @func-c() {
define weak void @func-d() { ret void }
; CHECK-DAG: define weak void @func-d() {

View File

@ -6,3 +6,7 @@
@kallsyms_names = extern_weak global [0 x i8]
@MyVar = extern_weak global i32
@Inte = extern_weak global i32
define weak [0 x i8]* @use_kallsyms_names() {
ret [0 x i8]* @kallsyms_names
}