| Duncan P. N. Exon Smith | fda0cee | 2014-12-18 01:05:33 +0000 | [diff] [blame] | 1 | ; RUN: llvm-link %s %S/Inputs/replaced-function-matches-first-subprogram.ll -S | FileCheck %s | 
|  | 2 |  | 
|  | 3 | ; Generated from C++ source: | 
|  | 4 | ; | 
|  | 5 | ; // repro/t.h | 
|  | 6 | ; template <class T> struct Class { | 
|  | 7 | ;   int foo() { return 0; } | 
|  | 8 | ; }; | 
|  | 9 | ; // repro/d1/t1.cpp | 
|  | 10 | ; #include "t.h" | 
|  | 11 | ; int foo() { return Class<int>().foo(); } | 
|  | 12 | ; // repro/d2/t2.cpp | 
|  | 13 | ; #include "t.h" | 
|  | 14 | ; template struct Class<int>; | 
|  | 15 |  | 
|  | 16 | %struct.Class = type { i8 } | 
|  | 17 |  | 
| Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 18 | ; CHECK: define i32 @_Z3foov(){{.*}} !dbg ![[SP1:[0-9]+]] | 
|  | 19 | define i32 @_Z3foov() !dbg !4 { | 
| Duncan P. N. Exon Smith | fda0cee | 2014-12-18 01:05:33 +0000 | [diff] [blame] | 20 | entry: | 
|  | 21 | %tmp = alloca %struct.Class, align 1 | 
|  | 22 | %call = call i32 @_ZN5ClassIiE3fooEv(%struct.Class* %tmp), !dbg !14 | 
|  | 23 | ret i32 %call, !dbg !14 | 
|  | 24 | } | 
|  | 25 |  | 
| Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 26 | ; CHECK: define weak_odr i32 @_ZN5ClassIiE3fooEv(%struct.Class* %this){{.*}} !dbg ![[SP2:[0-9]+]] { | 
| Duncan P. N. Exon Smith | fda0cee | 2014-12-18 01:05:33 +0000 | [diff] [blame] | 27 | ; CHECK-NOT: } | 
|  | 28 | ; CHECK: !dbg ![[LOC:[0-9]+]] | 
| Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 29 | define linkonce_odr i32 @_ZN5ClassIiE3fooEv(%struct.Class* %this) align 2 !dbg !7 { | 
| Duncan P. N. Exon Smith | fda0cee | 2014-12-18 01:05:33 +0000 | [diff] [blame] | 30 | entry: | 
|  | 31 | %this.addr = alloca %struct.Class*, align 8 | 
|  | 32 | store %struct.Class* %this, %struct.Class** %this.addr, align 8 | 
| David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 33 | %this1 = load %struct.Class*, %struct.Class** %this.addr | 
| Duncan P. N. Exon Smith | fda0cee | 2014-12-18 01:05:33 +0000 | [diff] [blame] | 34 | ret i32 0, !dbg !15 | 
|  | 35 | } | 
|  | 36 |  | 
|  | 37 | ; CHECK: !llvm.dbg.cu = !{![[CU1:[0-9]+]], ![[CU2:[0-9]+]]} | 
|  | 38 | !llvm.dbg.cu = !{!0} | 
|  | 39 | !llvm.module.flags = !{!10, !11, !12} | 
|  | 40 | !llvm.ident = !{!13} | 
|  | 41 |  | 
|  | 42 | ; Extract out the list of subprograms from each compile unit. | 
| Duncan P. N. Exon Smith | 55ca964 | 2015-08-03 17:26:41 +0000 | [diff] [blame] | 43 | ; CHECK-DAG: ![[CU1]] = distinct !DICompileUnit({{.*}} subprograms: ![[SPs1:[0-9]+]] | 
|  | 44 | ; CHECK-DAG: ![[CU2]] = distinct !DICompileUnit({{.*}} subprograms: ![[SPs2:[0-9]+]] | 
|  | 45 | !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.6.0 (trunk 224193) (llvm/trunk 224197)", isOptimized: false, emissionKind: 2, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) | 
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 46 | !1 = !DIFile(filename: "t1.cpp", directory: "/Users/dexonsmith/data/llvm/staging/test/Linker/repro/d1") | 
| Duncan P. N. Exon Smith | fda0cee | 2014-12-18 01:05:33 +0000 | [diff] [blame] | 47 | !2 = !{} | 
|  | 48 |  | 
| Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 49 | ; Extract out each compile unit's single subprogram.  The replaced subprogram's | 
|  | 50 | ; function should drop to null in the first compile unit. | 
| Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 51 | ; CHECK-DAG: ![[SPs1]] = !{![[SP1]], ![[SP2r:[0-9]+]]} | 
|  | 52 | ; CHECK-DAG: ![[SPs2]] = !{![[SP2]]} | 
| Duncan P. N. Exon Smith | fda0cee | 2014-12-18 01:05:33 +0000 | [diff] [blame] | 53 | !3 = !{!4, !7} | 
| Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 54 | !4 = distinct !DISubprogram(name: "foo", line: 2, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 2, file: !1, scope: !5, type: !6, variables: !2) | 
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 55 | !5 = !DIFile(filename: "t1.cpp", directory: "/Users/dexonsmith/data/llvm/staging/test/Linker/repro/d1") | 
|  | 56 | !6 = !DISubroutineType(types: !2) | 
| Duncan P. N. Exon Smith | fda0cee | 2014-12-18 01:05:33 +0000 | [diff] [blame] | 57 |  | 
| Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 58 | ; Extract out the file from the replaced subprogram. | 
|  | 59 | ; CHECK-DAG: ![[SP2]] = distinct !DISubprogram({{.*}} file: ![[FILE:[0-9]+]], | 
| Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 60 |  | 
|  | 61 | ; We can't use CHECK-NOT/CHECK-SAME with a CHECK-DAG, so rely on field order to | 
|  | 62 | ; prove that there's no function: here. | 
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 63 | ; CHECK-DAG: ![[SP2r]] = {{.*}}!DISubprogram({{.*}} isOptimized: false, variables: | 
| Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 64 | !7 = distinct !DISubprogram(name: "foo", line: 2, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 2, file: !8, scope: !9, type: !6, variables: !2) | 
| Duncan P. N. Exon Smith | fda0cee | 2014-12-18 01:05:33 +0000 | [diff] [blame] | 65 |  | 
|  | 66 | ; The new subprogram should be pointing at the new directory. | 
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 67 | ; CHECK-DAG: ![[FILE]] = !DIFile(filename: "../t.h", directory: "/Users/dexonsmith/data/llvm/staging/test/Linker/repro/d2") | 
|  | 68 | !8 = !DIFile(filename: "../t.h", directory: "/Users/dexonsmith/data/llvm/staging/test/Linker/repro/d1") | 
|  | 69 | !9 = !DIFile(filename: "../t.h", directory: "/Users/dexonsmith/data/llvm/staging/test/Linker/repro/d1") | 
| Duncan P. N. Exon Smith | fda0cee | 2014-12-18 01:05:33 +0000 | [diff] [blame] | 70 | !10 = !{i32 2, !"Dwarf Version", i32 2} | 
| Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 71 | !11 = !{i32 2, !"Debug Info Version", i32 3} | 
| Duncan P. N. Exon Smith | fda0cee | 2014-12-18 01:05:33 +0000 | [diff] [blame] | 72 | !12 = !{i32 1, !"PIC Level", i32 2} | 
|  | 73 | !13 = !{!"clang version 3.6.0 (trunk 224193) (llvm/trunk 224197)"} | 
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 74 | !14 = !DILocation(line: 2, column: 20, scope: !4) | 
| Duncan P. N. Exon Smith | fda0cee | 2014-12-18 01:05:33 +0000 | [diff] [blame] | 75 |  | 
|  | 76 | ; The same subprogram should be pointed to by inside the !dbg reference. | 
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 77 | ; CHECK: ![[LOC]] = !DILocation(line: 2, column: 15, scope: ![[SP2]]) | 
|  | 78 | !15 = !DILocation(line: 2, column: 15, scope: !7) |