xref: /llvm-project/llvm/test/CodeGen/AArch64/GlobalISel/constant-dbg-loc.ll (revision 8cb642bf18bfd3e6e8576f4f090fa584f68bb0cc)
1; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2; RUN: llc -mtriple aarch64 -O0 -stop-after=irtranslator -global-isel -verify-machineinstrs %s -o - 2>&1 | FileCheck --match-full-lines %s
3target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
4target triple = "arm64-apple-ios5.0.0"
5
6@var1 = common global i32 0, align 4, !dbg !0
7@var2 = common global i32 0, align 4, !dbg !6
8
9; We check here that the G_GLOBAL_VALUE has no debug loc.
10define i32 @main() #0 !dbg !14 {
11  ; CHECK-LABEL: name: main
12  ; CHECK: bb.1.entry:
13  ; CHECK-NEXT:   successors: %bb.2(0x40000000), %bb.3(0x40000000)
14  ; CHECK-NEXT: {{  $}}
15  ; CHECK-NEXT:   [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
16  ; CHECK-NEXT:   [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @var1
17  ; CHECK-NEXT:   [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
18  ; CHECK-NEXT:   [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
19  ; CHECK-NEXT:   [[GV1:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @var2
20  ; CHECK-NEXT:   [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0.retval
21  ; CHECK-NEXT:   G_STORE [[C]](s32), [[FRAME_INDEX]](p0) :: (store (s32) into %ir.retval)
22  ; CHECK-NEXT:   [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[GV]](p0), debug-location !17 :: (dereferenceable load (s32) from @var1)
23  ; CHECK-NEXT:   [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[LOAD]](s32), [[C1]], debug-location !19
24  ; CHECK-NEXT:   G_BRCOND [[ICMP]](s1), %bb.2, debug-location !20
25  ; CHECK-NEXT:   G_BR %bb.3, debug-location !20
26  ; CHECK-NEXT: {{  $}}
27  ; CHECK-NEXT: bb.2.if.then:
28  ; CHECK-NEXT:   successors: %bb.3(0x80000000)
29  ; CHECK-NEXT: {{  $}}
30  ; CHECK-NEXT:   G_STORE [[C2]](s32), [[GV1]](p0), debug-location !21 :: (store (s32) into @var2)
31  ; CHECK-NEXT:   G_BR %bb.3, debug-location !23
32  ; CHECK-NEXT: {{  $}}
33  ; CHECK-NEXT: bb.3.if.end:
34  ; CHECK-NEXT:   $w0 = COPY [[C]](s32), debug-location !24
35  ; CHECK-NEXT:   RET_ReallyLR implicit $w0, debug-location !24
36entry:
37  %retval = alloca i32, align 4
38  store i32 0, ptr %retval, align 4
39  %0 = load i32, ptr @var1, align 4, !dbg !17
40  %cmp = icmp eq i32 %0, 1, !dbg !19
41  br i1 %cmp, label %if.then, label %if.end, !dbg !20
42
43if.then:
44  store i32 2, ptr @var2, align 4, !dbg !21
45  br label %if.end, !dbg !23
46
47if.end:
48  ret i32 0, !dbg !24
49}
50
51!llvm.dbg.cu = !{!2}
52!llvm.module.flags = !{!9, !10, !11, !12}
53!llvm.ident = !{!13}
54
55!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
56!1 = distinct !DIGlobalVariable(name: "var1", scope: !2, file: !3, line: 1, type: !8, isLocal: false, isDefinition: true)
57!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: GNU)
58!3 = !DIFile(filename: "dbg.c", directory: "/")
59!4 = !{}
60!5 = !{!0, !6}
61!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
62!7 = distinct !DIGlobalVariable(name: "var2", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
63!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
64!9 = !{i32 2, !"Dwarf Version", i32 2}
65!10 = !{i32 2, !"Debug Info Version", i32 3}
66!11 = !{i32 1, !"wchar_size", i32 4}
67!12 = !{i32 7, !"PIC Level", i32 2}
68!13 = !{!"clang"}
69!14 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 3, type: !15, scopeLine: 3, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4)
70!15 = !DISubroutineType(types: !16)
71!16 = !{!8}
72!17 = !DILocation(line: 4, column: 7, scope: !18)
73!18 = distinct !DILexicalBlock(scope: !14, file: !3, line: 4, column: 7)
74!19 = !DILocation(line: 4, column: 12, scope: !18)
75!20 = !DILocation(line: 4, column: 7, scope: !14)
76!21 = !DILocation(line: 5, column: 10, scope: !22)
77!22 = distinct !DILexicalBlock(scope: !18, file: !3, line: 4, column: 18)
78!23 = !DILocation(line: 6, column: 3, scope: !22)
79!24 = !DILocation(line: 7, column: 3, scope: !14)
80