Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/DebugInfo/X86/tail-merge.ll

raw
1 ; RUN: llvm-as < %s -o %t.bc
2 ; RUN: llvm-spirv %t.bc -o %t.spv
3 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o - | llvm-dis -o %t.ll
4
5 ; RUN: llc %t.ll -mtriple=x86_64-unknown-unknown -use-unknown-locations=Enable -o - | FileCheck %s
6
7 ; Generated with "clang -gline-tables-only -c -emit-llvm -o - | opt -sroa -S"
8 ; from source:
9 ;
10 ; extern int foo(int);
11 ; extern int bar(int);
12 ;
13 ; int test(int a, int b) {
14 ; if(b)
15 ; a += foo(a);
16 ; else
17 ; a += bar(a);
18 ; return a;
19 ; }
20
21 ; When tail-merging the debug location of the common tail should be removed.
22
23 ; CHECK-LABEL: test:
24 ; CHECK: movl %edi, [[REG:%.*]]
25 ; CHECK: testl %esi, %esi
26 ; CHECK: je [[ELSE:.LBB[0-9]+_[0-9]+]]
27 ; CHECK: .loc 1 6 10
28 ; CHECK: callq foo
29 ; CHECK: jmp [[TAIL:.LBB[0-9]+_[0-9]+]]
30 ; CHECK: [[ELSE]]:
31 ; CHECK: .loc 1 8 10
32 ; CHECK: callq bar
33 ; CHECK: [[TAIL]]:
34 ; CHECK: .loc 1 0
35 ; CHECK: addl [[REG]], %eax
36 ; CHECK: .loc 1 9 3
37
38 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
39 target triple = "spir64-unknown-unknown"
40
41 define i32 @test(i32 %a, i32 %b) !dbg !6 {
42 entry:
43 %tobool = icmp ne i32 %b, 0, !dbg !8
44 br i1 %tobool, label %if.then, label %if.else, !dbg !8
45
46 if.then: ; preds = %entry
47 %call = call i32 @foo(i32 %a), !dbg !9
48 %add = add nsw i32 %a, %call, !dbg !10
49 br label %if.end, !dbg !11
50
51 if.else: ; preds = %entry
52 %call1 = call i32 @bar(i32 %a), !dbg !12
53 %add2 = add nsw i32 %a, %call1, !dbg !13
54 br label %if.end
55
56 if.end: ; preds = %if.else, %if.then
57 %a.addr.0 = phi i32 [ %add, %if.then ], [ %add2, %if.else ]
58 ret i32 %a.addr.0, !dbg !14
59 }
60
61 declare i32 @foo(i32)
62 declare i32 @bar(i32)
63
64 !llvm.dbg.cu = !{!0}
65 !llvm.module.flags = !{!3, !4}
66
67 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)
68 !1 = !DIFile(filename: "test.c", directory: "")
69 !2 = !{}
70 !3 = !{i32 2, !"Dwarf Version", i32 4}
71 !4 = !{i32 2, !"Debug Info Version", i32 3}
72 !6 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 4, type: !7, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
73 !7 = !DISubroutineType(types: !2)
74 !8 = !DILocation(line: 5, column: 6, scope: !6)
75 !9 = !DILocation(line: 6, column: 10, scope: !6)
76 !10 = !DILocation(line: 6, column: 7, scope: !6)
77 !11 = !DILocation(line: 6, column: 5, scope: !6)
78 !12 = !DILocation(line: 8, column: 10, scope: !6)
79 !13 = !DILocation(line: 8, column: 7, scope: !6)
80 !14 = !DILocation(line: 9, column: 3, scope: !6)