Always treat DISubprogram reached by DIImportedEntity as needed.
[oota-llvm.git] / test / Linker / subprogram-linkonce-weak.ll
index 598cea7afeb058b1196732bc45398f0469f29ff4..e8bc67765bb80cc54b0251b8e78e0431ae94700f 100644 (file)
@@ -2,6 +2,7 @@
 ; RUN: FileCheck %s -check-prefix=LW -check-prefix=CHECK <%t1
 ; RUN: llvm-link %S/Inputs/subprogram-linkonce-weak.ll %s -S -o %t2
 ; RUN: FileCheck %s -check-prefix=WL -check-prefix=CHECK <%t2
+; REQUIRES: default_triple
 
 ; This testcase tests the following flow:
 ;  - File A defines a linkonce version of @foo which has inlined into @bar.
 ; The WL prefix means weak (the other file) first, then linkonce (this file).
 
 ; We'll see @bar before @foo if this file is first.
-; LW-LABEL: define i32 @bar(
+; LW: define i32 @bar({{.*}} !dbg ![[BARSP:[0-9]+]]
 ; LW: %sum = add i32 %a, %b, !dbg ![[FOOINBAR:[0-9]+]]
 ; LW: ret i32 %sum, !dbg ![[BARRET:[0-9]+]]
-; LW-LABEL: define weak i32 @foo(
+; LW: define weak i32 @foo({{.*}} !dbg ![[WEAKFOOSP:[0-9]+]]
 ; LW: %sum = call i32 @fastadd(i32 %a, i32 %b), !dbg ![[FOOCALL:[0-9]+]]
 ; LW: ret i32 %sum, !dbg ![[FOORET:[0-9]+]]
 
 ; We'll see @foo before @bar if this file is second.
-; WL-LABEL: define weak i32 @foo(
+; WL: define weak i32 @foo({{.*}} !dbg ![[WEAKFOOSP:[0-9]+]]
 ; WL: %sum = call i32 @fastadd(i32 %a, i32 %b), !dbg ![[FOOCALL:[0-9]+]]
 ; WL: ret i32 %sum, !dbg ![[FOORET:[0-9]+]]
-; WL-LABEL: define i32 @bar(
+; WL: define i32 @bar({{.*}} !dbg ![[BARSP:[0-9]+]]
 ; WL: %sum = add i32 %a, %b, !dbg ![[FOOINBAR:[0-9]+]]
 ; WL: ret i32 %sum, !dbg ![[BARRET:[0-9]+]]
 
-define i32 @bar(i32 %a, i32 %b) {
+define i32 @bar(i32 %a, i32 %b) !dbg !3 {
 entry:
   %sum = add i32 %a, %b, !dbg !DILocation(line: 2, scope: !4,
                                           inlinedAt: !DILocation(line: 12, scope: !3))
   ret i32 %sum, !dbg !DILocation(line: 13, scope: !3)
 }
 
-define linkonce i32 @foo(i32 %a, i32 %b) {
+define linkonce i32 @foo(i32 %a, i32 %b) !dbg !4 {
 entry:
   %sum = add i32 %a, %b, !dbg !DILocation(line: 2, scope: !4)
   ret i32 %sum, !dbg !DILocation(line: 3, scope: !4)
@@ -52,17 +53,13 @@ entry:
 ; WL-SAME: !{![[WCU:[0-9]+]], ![[LCU:[0-9]+]]}
 !llvm.dbg.cu = !{!1}
 
-; LW: ![[LCU]] = !DICompileUnit({{.*}} subprograms: ![[LSPs:[0-9]+]]
-; LW: ![[LSPs]] = !{![[BARSP:[0-9]+]], ![[FOOSP:[0-9]+]]}
-; LW: ![[BARSP]] = !DISubprogram(name: "bar",
-; LW-SAME: function: i32 (i32, i32)* @bar
-; LW: ![[FOOSP]] = {{.*}}!DISubprogram(name: "foo",
-; LW-NOT: function:
-; LW-SAME: ){{$}}
-; LW: ![[WCU]] = !DICompileUnit({{.*}} subprograms: ![[WSPs:[0-9]+]]
-; LW: ![[WSPs]] = !{![[WEAKFOOSP:[0-9]+]]}
-; LW: ![[WEAKFOOSP]] = !DISubprogram(name: "foo",
-; LW-SAME: function: i32 (i32, i32)* @foo
+; LW: ![[LCU]] = distinct !DICompileUnit({{.*}} subprograms: ![[LSPs:[0-9]+]]
+; LW: ![[LSPs]] = !{![[BARSP]], ![[FOOSP:[0-9]+]]}
+; LW: ![[BARSP]] = distinct !DISubprogram(name: "bar",
+; LW: ![[FOOSP]] = distinct !DISubprogram(name: "foo",
+; LW: ![[WCU]] = distinct !DICompileUnit({{.*}} subprograms: ![[WSPs:[0-9]+]]
+; LW: ![[WSPs]] = !{![[WEAKFOOSP]]}
+; LW: ![[WEAKFOOSP]] = distinct !DISubprogram(name: "foo",
 ; LW: ![[FOOINBAR]] = !DILocation(line: 2, scope: ![[FOOSP]], inlinedAt: ![[BARIA:[0-9]+]])
 ; LW: ![[BARIA]] = !DILocation(line: 12, scope: ![[BARSP]])
 ; LW: ![[BARRET]] = !DILocation(line: 13, scope: ![[BARSP]])
@@ -70,27 +67,23 @@ entry:
 ; LW: ![[FOORET]] = !DILocation(line: 53, scope: ![[WEAKFOOSP]])
 
 ; Same as above, but reordered.
-; WL: ![[WCU]] = !DICompileUnit({{.*}} subprograms: ![[WSPs:[0-9]+]]
-; WL: ![[WSPs]] = !{![[WEAKFOOSP:[0-9]+]]}
-; WL: ![[WEAKFOOSP]] = !DISubprogram(name: "foo",
-; WL-SAME: function: i32 (i32, i32)* @foo
-; WL: ![[LCU]] = !DICompileUnit({{.*}} subprograms: ![[LSPs:[0-9]+]]
+; WL: ![[WCU]] = distinct !DICompileUnit({{.*}} subprograms: ![[WSPs:[0-9]+]]
+; WL: ![[WSPs]] = !{![[WEAKFOOSP]]}
+; WL: ![[WEAKFOOSP]] = distinct !DISubprogram(name: "foo",
+; WL: ![[LCU]] = distinct !DICompileUnit({{.*}} subprograms: ![[LSPs:[0-9]+]]
 ; WL: ![[LSPs]] = !{![[BARSP:[0-9]+]], ![[FOOSP:[0-9]+]]}
-; WL: ![[BARSP]] = !DISubprogram(name: "bar",
-; WL-SAME: function: i32 (i32, i32)* @bar
-; WL: ![[FOOSP]] = {{.*}}!DISubprogram(name: "foo",
-; Note, for symmetry, this should be "NOT: function:" and "SAME: ){{$}}".
-; WL-SAME: function: i32 (i32, i32)* @foo
+; WL: ![[BARSP]] = distinct !DISubprogram(name: "bar",
+; WL: ![[FOOSP]] = distinct !DISubprogram(name: "foo",
 ; WL: ![[FOOCALL]] = !DILocation(line: 52, scope: ![[WEAKFOOSP]])
 ; WL: ![[FOORET]] = !DILocation(line: 53, scope: ![[WEAKFOOSP]])
 ; WL: ![[FOOINBAR]] = !DILocation(line: 2, scope: ![[FOOSP]], inlinedAt: ![[BARIA:[0-9]+]])
 ; WL: ![[BARIA]] = !DILocation(line: 12, scope: ![[BARSP]])
 ; WL: ![[BARRET]] = !DILocation(line: 13, scope: ![[BARSP]])
 
-!1 = !DICompileUnit(language: DW_LANG_C99, file: !2, subprograms: !{!3, !4}, emissionKind: 1)
+!1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, subprograms: !{!3, !4}, emissionKind: 1)
 !2 = !DIFile(filename: "bar.c", directory: "/path/to/dir")
-!3 = !DISubprogram(file: !2, scope: !2, line: 11, name: "bar", function: i32 (i32, i32)* @bar, type: !5)
-!4 = !DISubprogram(file: !2, scope: !2, line: 1, name: "foo", function: i32 (i32, i32)* @foo, type: !5)
+!3 = distinct !DISubprogram(file: !2, scope: !2, line: 11, name: "bar", type: !5)
+!4 = distinct !DISubprogram(file: !2, scope: !2, line: 1, name: "foo", type: !5)
 !5 = !DISubroutineType(types: !{})
 
 ; Crasher for llc.