xref: /llvm-project/llvm/test/CodeGen/X86/xor-combine-debugloc.ll (revision 9cac4e6d1403554b06ec2fc9d834087b1234b695)
1; RUN: llc -stop-after=finalize-isel < %s | FileCheck %s
2;
3; Make sure that when the entry block of IR below is lowered, an instruction
4; that implictly defines $eflags has a same debug location with the icmp
5; instruction, and the branch instructions have a same debug location with the
6; br instruction.
7;
8; CHECK:      [[DLOC1:![0-9]+]] = !DILocation(line: 5, column: 9, scope: !{{[0-9]+}})
9; CHECK:      [[DLOC2:![0-9]+]] = !DILocation(line: 5, column: 7, scope: !{{[0-9]+}})
10; CHECK-DAG:  [[VREG1:%[^ ]+]]:gr32 = COPY $esi
11; CHECK-DAG:  [[VREG2:%[^ ]+]]:gr32 = COPY $edi
12; CHECK:      SUB32rr [[VREG2]], [[VREG1]], implicit-def $eflags, debug-location [[DLOC1]]
13; CHECK-NEXT: JCC_1{{.*}} 4, implicit $eflags, debug-location [[DLOC2]]
14; CHECK-NEXT: JMP_1{{.*}} debug-location [[DLOC2]]
15
16target triple = "x86_64-unknown-linux-gnu"
17
18; Function Attrs: nounwind uwtable
19define i32 @foo(i32 %x, i32 %y) !dbg !4 {
20entry:
21  tail call void @llvm.dbg.value(metadata i32 %x, i64 0, metadata !9, metadata !11), !dbg !12
22  tail call void @llvm.dbg.value(metadata i32 %y, i64 0, metadata !10, metadata !11), !dbg !13
23  %cmp = icmp ne i32 %x, %y, !dbg !14
24  br i1 %cmp, label %if.then, label %if.else, !dbg !16
25
26if.then:                                          ; preds = %entry
27  %call = tail call i32 (...) @bar() #3, !dbg !17
28  br label %return, !dbg !18
29
30if.else:                                          ; preds = %entry
31  %call1 = tail call i32 (...) @baz() #3, !dbg !19
32  br label %return, !dbg !20
33
34return:                                           ; preds = %if.else, %if.then
35  %retval.0 = phi i32 [ %call, %if.then ], [ %call1, %if.else ]
36  ret i32 %retval.0, !dbg !21
37}
38
39declare i32 @bar(...)
40declare i32 @baz(...)
41
42; Function Attrs: nounwind readnone
43declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
44
45!llvm.dbg.cu = !{!0}
46!llvm.module.flags = !{!2, !3}
47
48!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
49!1 = !DIFile(filename: "foo.c", directory: "b/")
50!2 = !{i32 2, !"Dwarf Version", i32 4}
51!3 = !{i32 2, !"Debug Info Version", i32 3}
52!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !5, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !8)
53!5 = !DISubroutineType(types: !6)
54!6 = !{!7, !7, !7}
55!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
56!8 = !{!9, !10}
57!9 = !DILocalVariable(name: "x", arg: 1, scope: !4, file: !1, line: 4, type: !7)
58!10 = !DILocalVariable(name: "y", arg: 2, scope: !4, file: !1, line: 4, type: !7)
59!11 = !DIExpression()
60!12 = !DILocation(line: 4, column: 13, scope: !4)
61!13 = !DILocation(line: 4, column: 20, scope: !4)
62!14 = !DILocation(line: 5, column: 9, scope: !15)
63!15 = distinct !DILexicalBlock(scope: !4, file: !1, line: 5, column: 7)
64!16 = !DILocation(line: 5, column: 7, scope: !4)
65!17 = !DILocation(line: 6, column: 12, scope: !15)
66!18 = !DILocation(line: 6, column: 5, scope: !15)
67!19 = !DILocation(line: 8, column: 12, scope: !15)
68!20 = !DILocation(line: 8, column: 5, scope: !15)
69!21 = !DILocation(line: 9, column: 1, scope: !4)
70