Home | History | Annotate | Download | only in Linker
      1 ; RUN: llvm-as < %s > %t.bc
      2 ; RUN: llvm-as < %p/testlink2.ll > %t2.bc
      3 ; RUN: llvm-link %t.bc %t2.bc -S | FileCheck %s
      4 
      5 ; CHECK: %Ty2 = type { %Ty1* }
      6 ; CHECK: %Ty1 = type { %Ty2* }
      7 %Ty1 = type opaque
      8 %Ty2 = type { %Ty1* }
      9 
     10 ; CHECK: %intlist = type { %intlist*, i32 }
     11 %intlist = type { %intlist*, i32 }
     12 
     13 ; The uses of intlist in the other file should be remapped.
     14 ; CHECK-NOT: {{%intlist.[0-9]}}
     15 
     16 %Struct1 = type opaque
     17 @S1GV = external global %Struct1*
     18 
     19 
     20 @GVTy1 = external global %Ty1*
     21 @GVTy2 = global %Ty2* null
     22 
     23 
     24 ; This should stay the same
     25 ; CHECK: @MyIntList = global %intlist { %intlist* null, i32 17 }
     26 @MyIntList = global %intlist { %intlist* null, i32 17 }
     27 
     28 
     29 ; Nothing to link here.
     30 
     31 ; CHECK: @0 = external global i32
     32 @0 = external global i32
     33 ; CHECK: @Inte = global i32 1
     34 @Inte = global i32 1
     35 
     36 ; Intern1 is intern in both files, rename testlink2's.
     37 ; CHECK: @Intern1 = internal constant i32 42
     38 @Intern1 = internal constant i32 42
     39 
     40 ; This should get renamed since there is a definition that is non-internal in
     41 ; the other module.
     42 ; CHECK: @Intern2{{[0-9]+}} = internal constant i32 792
     43 @Intern2 = internal constant i32 792
     44 
     45 
     46 ; CHECK: @MyVarPtr = linkonce global { i32* } { i32* @MyVar }
     47 @MyVarPtr = linkonce global { i32* } { i32* @MyVar }
     48 
     49 ; CHECK: @MyVar = global i32 4
     50 @MyVar = external global i32
     51 
     52 ; Take value from other module.
     53 ; CHECK: AConst = constant i32 1234
     54 @AConst = linkonce constant i32 123
     55 
     56 ; Renamed version of Intern1.
     57 ; CHECK: @Intern1{{[0-9]+}} = internal constant i32 52
     58 
     59 
     60 ; Globals linked from testlink2.
     61 ; CHECK: @Intern2 = constant i32 12345
     62 
     63 ; CHECK: @MyIntListPtr = constant 
     64 ; CHECK: @1 = constant i32 412
     65 
     66 
     67 declare i32 @foo(i32)
     68 
     69 declare void @print(i32)
     70 
     71 define void @main() {
     72   %v1 = load i32* @MyVar
     73   call void @print(i32 %v1)
     74   %idx = getelementptr %intlist* @MyIntList, i64 0, i32 1
     75   %v2 = load i32* %idx
     76   call void @print(i32 %v2)
     77   %1 = call i32 @foo(i32 5)
     78   %v3 = load i32* @MyVar
     79   call void @print(i32 %v3)
     80   %v4 = load i32* %idx
     81   call void @print(i32 %v4)
     82   ret void
     83 }
     84 
     85 define internal void @testintern() {
     86   ret void
     87 }
     88 
     89 define internal void @Testintern() {
     90   ret void
     91 }
     92 
     93 define void @testIntern() {
     94   ret void
     95 }
     96