We already linked available_externally and linkonce lazily, this just
adds declarations to the list.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254917
91177308-0d34-0410-b5e6-
96231b3b80d8
GV.hasAvailableExternallyLinkage()))
return false;
+ if (GV.isDeclaration())
+ return false;
+
if (const Comdat *SC = GV.getComdat()) {
bool LinkFromSrc;
Comdat::SelectionKind SK;
declare void @foo()
+define void @use_foo() {
+ call void @foo()
+ ret void
+}
; 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() {
; 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
+}
getelementptr %A, %A* null, i32 0
ret void
}
+
+define %A* @use_g2() {
+ ret %A* @g2
+}
+
+define %B* @use_g3() {
+ ret %B* @g3
+}
ret void
}
-declare void @VecSizeCrash1(%VecSize)
+define void @VecSizeCrash1(%VecSize) {
+ ret void
+}
%A.11 = type { %B }
%B = type { i8 }
@g1 = external global %A.11
+
+define %A.11* @use_g1() {
+ ret %A.11* @g1
+}
%A.11 = type opaque
@g2 = external global %A.11
+
+define %A.11* @use_g2() {
+ ret %A.11* @g2
+}
%C = type { %A }
@g1 = external global %B
+
+define %B* @use_g1() {
+ ret %B* @g1
+}
; 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
ret void
}
-declare void @VecSizeCrash(%VecSize)
+define void @VecSizeCrash(%VecSize) {
+ ret void
+}
%A = type { %B }
%B = type { i8 }
@g3 = external global %A
+
+define %A* @use_g3() {
+ ret %A* @g3
+}
; 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 }
getelementptr %C, %C* null, i64 0, i32 0, i32 0
ret void
}
-@g1 = external global %C.0
+@g1 = global %C.0 zeroinitializer
@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
; 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() {
@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
+}