xref: /llvm-project/llvm/test/DebugInfo/MIR/InstrRef/pick-vphi-in-shifting-loop.mir (revision 9f8544713ad8e57fb74cbfce3fbc7fff523e549f)
1b5426cedSJeremy Morse# RUN: llc %s -o - -run-pass=livedebugvalues \
2b5426cedSJeremy Morse# RUN:     -experimental-debug-variable-locations \
3b5426cedSJeremy Morse# RUN: | FileCheck %s
4b5426cedSJeremy Morse#
5b5426cedSJeremy Morse# This test used to cause an infinite loop in InstrRefBasedLDV. Observe block
6b5426cedSJeremy Morse# five: on the first entry the desired variable value is in $rdx and $rcx, on
7b5426cedSJeremy Morse# both paths to the block. However, the block rotates values between those
8b5426cedSJeremy Morse# registers, and feeds a zero-value in too. Ultimately, there is no correct
9b5426cedSJeremy Morse# location for the variable in that block.
10b5426cedSJeremy Morse# This caused an infinite loop in a previous implementation of LiveDebugValues.
11b5426cedSJeremy Morse# Keep this around as a regression test, and check that no location is picked
12b5426cedSJeremy Morse# in block 5.
13b5426cedSJeremy Morse#
14b5426cedSJeremy Morse# CHECK-LABEL: bb.3:
15e10e9363SStephen Tozer# CHECK:       DBG_INSTR_REF {{.+}}, dbg-instr-ref(7, 0)
16c383f4d6SStephen Tozer# CHECK-NEXT:  DBG_VALUE_LIST {{.+}}, $rdx
17b5426cedSJeremy Morse# CHECK-NEXT:  $rcx = MOV64rr $rdx
18b5426cedSJeremy Morse# CHECK-LABEL: bb.4:
19c383f4d6SStephen Tozer# CHECK:       DBG_VALUE_LIST {{.+}}, $rcx
20b5426cedSJeremy Morse# CHECK-NEXT:  $rdx = MOV64rr killed $rcx
21b5426cedSJeremy Morse# CHECK-LABEL: bb.5:
22a7fa5febSZequan Wu# CHECK-NOT:   DBG_VALUE
23b5426cedSJeremy Morse--- |
24b5426cedSJeremy Morse  target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
25b5426cedSJeremy Morse  target triple = "x86_64-unknown-linux-gnu"
26b5426cedSJeremy Morse
27b5426cedSJeremy Morse  ; Function Attrs: nofree norecurse nosync nounwind readonly uwtable
28b5426cedSJeremy Morse  define dso_local void @bees() local_unnamed_addr !dbg !13 {
29b5426cedSJeremy Morse  entry:
30b5426cedSJeremy Morse    ret void, !dbg !22
31b5426cedSJeremy Morse  }
32b5426cedSJeremy Morse
33b5426cedSJeremy Morse  ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
34b5426cedSJeremy Morse  declare void @llvm.dbg.value(metadata, metadata, metadata)
35b5426cedSJeremy Morse
36b5426cedSJeremy Morse  !llvm.dbg.cu = !{!2}
37b5426cedSJeremy Morse  !llvm.module.flags = !{!8, !9, !10, !11}
38b5426cedSJeremy Morse  !llvm.ident = !{!12}
39b5426cedSJeremy Morse
40b5426cedSJeremy Morse  !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
41b5426cedSJeremy Morse  !1 = distinct !DIGlobalVariable(name: "xmlNormalizeURIPath_path", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
42b5426cedSJeremy Morse  !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 10.0 (git@github.com:llvm/llvm-project 9d8de79d09c9560c094d90b010e8315fe2712ec2)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
43b5426cedSJeremy Morse  !3 = !DIFile(filename: "test4.c", directory: "/tmp")
44b5426cedSJeremy Morse  !4 = !{}
45b5426cedSJeremy Morse  !5 = !{!0}
46b5426cedSJeremy Morse  !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)
47b5426cedSJeremy Morse  !7 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
48b5426cedSJeremy Morse  !8 = !{i32 7, !"Dwarf Version", i32 4}
49b5426cedSJeremy Morse  !9 = !{i32 2, !"Debug Info Version", i32 3}
50b5426cedSJeremy Morse  !10 = !{i32 1, !"wchar_size", i32 4}
51b5426cedSJeremy Morse  !11 = !{i32 7, !"uwtable", i32 1}
52b5426cedSJeremy Morse  !12 = !{!"clang version 10.0 (git@github.com:llvm/llvm-project 9d8de79d09c9560c094d90b010e8315fe2712ec2)"}
53b5426cedSJeremy Morse  !13 = distinct !DISubprogram(name: "xmlNormalizeURIPath", scope: !3, file: !3, line: 2, type: !14, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !16)
54b5426cedSJeremy Morse  !14 = !DISubroutineType(types: !15)
55b5426cedSJeremy Morse  !15 = !{null}
56b5426cedSJeremy Morse  !16 = !{!17, !18}
57b5426cedSJeremy Morse  !17 = !DILocalVariable(name: "cur", scope: !13, file: !3, line: 3, type: !6)
58b5426cedSJeremy Morse  !18 = !DILocalVariable(name: "segp", scope: !19, file: !3, line: 5, type: !6)
59b5426cedSJeremy Morse  !19 = distinct !DILexicalBlock(scope: !13, file: !3, line: 4, column: 13)
60b5426cedSJeremy Morse  !20 = !DILocation(line: 4, column: 3, scope: !13)
61b5426cedSJeremy Morse  !21 = !DILocation(line: 0, scope: !13)
62b5426cedSJeremy Morse  !22 = !DILocation(line: 0, scope: !19)
63b5426cedSJeremy Morse  !23 = !DILocation(line: 6, column: 5, scope: !19)
64b5426cedSJeremy Morse  !24 = !DILocation(line: 6, column: 12, scope: !19)
65b5426cedSJeremy Morse  !25 = !{!26, !26, i64 0}
66b5426cedSJeremy Morse  !26 = !{!"omnipotent char", !27, i64 0}
67b5426cedSJeremy Morse  !27 = !{!"Simple C/C++ TBAA"}
68b5426cedSJeremy Morse  !28 = !DILocation(line: 6, column: 27, scope: !19)
69b5426cedSJeremy Morse  !29 = !DILocation(line: 7, column: 7, scope: !19)
70b5426cedSJeremy Morse  !30 = distinct !{!30, !23, !31, !32, !33}
71b5426cedSJeremy Morse  !31 = !DILocation(line: 7, column: 9, scope: !19)
72b5426cedSJeremy Morse  !32 = !{!"llvm.loop.mustprogress"}
73b5426cedSJeremy Morse  !33 = !{!"llvm.loop.unroll.disable"}
74b5426cedSJeremy Morse
75b5426cedSJeremy Morse...
76b5426cedSJeremy Morse---
77b5426cedSJeremy Morsename:            bees
78b5426cedSJeremy Morsealignment:       16
79b5426cedSJeremy MorsetracksRegLiveness: true
80*9f854471SJeremy MorsedebugInstrRef: true
81b5426cedSJeremy MorseframeInfo:
82b5426cedSJeremy Morse  maxAlignment:    1
83b5426cedSJeremy Morse  maxCallFrameSize: 0
84b5426cedSJeremy MorsemachineFunctionInfo: {}
85b5426cedSJeremy Morsebody:             |
86b5426cedSJeremy Morse  bb.0:
87b5426cedSJeremy Morse    $rdx = MOV64ri 0, implicit-def $eflags
88b5426cedSJeremy Morse    $esi = MOV32ri 0, implicit-def $eflags
89b5426cedSJeremy Morse
90b5426cedSJeremy Morse  bb.1:
91b5426cedSJeremy Morse    successors: %bb.2(0x03e0f83e), %bb.1(0x7c1f07c2)
92b5426cedSJeremy Morse    liveins: $rcx, $rdi, $rdx, $eflags
93b5426cedSJeremy Morse
94b5426cedSJeremy Morse    DBG_PHI $rcx, 2
95c383f4d6SStephen Tozer    DBG_INSTR_REF !18, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(2, 0), debug-location !22
96b5426cedSJeremy Morse    JCC_1 %bb.1, 4, implicit $eflags, debug-location !22
97b5426cedSJeremy Morse
98b5426cedSJeremy Morse  bb.2:
99b5426cedSJeremy Morse    successors: %bb.4(0x30000000), %bb.3(0x50000000)
100b5426cedSJeremy Morse    liveins: $rcx, $rdi, $eflags
101b5426cedSJeremy Morse
102b5426cedSJeremy Morse    JCC_1 %bb.4, 4, implicit $eflags, debug-location !22
103b5426cedSJeremy Morse
104b5426cedSJeremy Morse  bb.3:
105b5426cedSJeremy Morse    successors: %bb.5(0x04000000)
106b5426cedSJeremy Morse    liveins: $rcx, $rdi, $eflags
107b5426cedSJeremy Morse
108b5426cedSJeremy Morse    $rdx = MOV64ri 0, debug-instr-number 7, debug-location !22
109c383f4d6SStephen Tozer    DBG_INSTR_REF !18, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(7, 0), debug-location !22
110b5426cedSJeremy Morse    $rcx = MOV64rr $rdx
111b5426cedSJeremy Morse    JMP_1 %bb.5, debug-location !22
112b5426cedSJeremy Morse
113b5426cedSJeremy Morse  bb.4:
114b5426cedSJeremy Morse    liveins: $rcx, $rdi, $eflags
115b5426cedSJeremy Morse
116b5426cedSJeremy Morse    $rdx = MOV64rr killed $rcx, debug-location !22
117b5426cedSJeremy Morse
118b5426cedSJeremy Morse  bb.5:
119b5426cedSJeremy Morse    successors: %bb.5(0x7c000000), %bb.6(0x04000000)
120b5426cedSJeremy Morse    liveins: $rdi, $rdx, $eflags
121b5426cedSJeremy Morse
122b5426cedSJeremy Morse    $rcx = MOV64rr $rdx, debug-location !22
123b5426cedSJeremy Morse    $rdx = MOV64ri 0 ; jmorse -- disabling this makes variable live-through
124b5426cedSJeremy Morse    JCC_1 %bb.5, 6, implicit $eflags, debug-location !22
125b5426cedSJeremy Morse
126b5426cedSJeremy Morse  bb.6:
127d391e4feSSimon Pilgrim    RET64 debug-location !22
128b5426cedSJeremy Morse
129b5426cedSJeremy Morse...
130