1 # RUN: llc -run-pass=early-tailduplication -mtriple=x86_64-unknown-linux-gnu %s -o - | FileCheck %s
3 # Tail Duplication may update SSA values and invalidate any DBG_VALUEs that
4 # use those values; those DBG_VALUEs should be set undef. This is tested
5 # for DBG_VALUE users, and DBG_VALUE_LISTs that use the value multiple times.
7 # CHECK: ![[VAR_J:[0-9]+]] = !DILocalVariable(name: "j"
8 # CHECK: ![[VAR_K:[0-9]+]] = !DILocalVariable(name: "k"
10 # CHECK: %[[REGISTER:[0-9]+]]:gr32 = PHI
11 # CHECK-LABEL: bb.2.if.end4:
12 # CHECK: DBG_VALUE_LIST ![[VAR_J]],
13 # CHECK-SAME: %[[REGISTER]], 1, %[[REGISTER]]
14 # CHECK: DBG_VALUE %[[REGISTER]], $noreg, ![[VAR_K]]
17 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
18 target triple = "x86_64-unknown-linux-gnu"
20 define dso_local void @main() local_unnamed_addr #0 !dbg !15 {
24 L: ; preds = %L, %L.outer
25 %tobool2.not = icmp eq i32 undef, 0
26 br i1 %tobool2.not, label %if.end4, label %L
29 call void @llvm.dbg.value(metadata !DIArgList(i32 %f.0.ph, i32 1, i32 %f.0.ph), metadata !19, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_LLVM_arg, 2, DW_OP_and, DW_OP_or, DW_OP_stack_value)), !dbg !21
30 %cmp = icmp slt i32 %f.0.ph, undef
31 br i1 %cmp, label %if.then5, label %if.end6
33 if.then5: ; preds = %if.end4
37 L.outer: ; preds = %if.then5, %entry
38 %f.0.ph = phi i32 [ 0, %if.then5 ], [ 1, %entry ]
41 if.end6: ; preds = %if.end4
45 declare dso_local void @h() local_unnamed_addr
47 declare void @llvm.dbg.value(metadata, metadata, metadata)
50 !llvm.module.flags = !{!13, !14}
52 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, splitDebugInlining: false, nameTableKind: None)
53 !1 = !DIFile(filename: "tail-dup-debugvalue.c", directory: "/tmp")
55 !3 = !{!4, !7, !9, !11}
56 !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())
57 !5 = distinct !DIGlobalVariable(name: "a", scope: !0, file: !1, line: 2, type: !6, isLocal: false, isDefinition: true)
58 !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
59 !7 = !DIGlobalVariableExpression(var: !8, expr: !DIExpression())
60 !8 = distinct !DIGlobalVariable(name: "b", scope: !0, file: !1, line: 2, type: !6, isLocal: false, isDefinition: true)
61 !9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression())
62 !10 = distinct !DIGlobalVariable(name: "c", scope: !0, file: !1, line: 2, type: !6, isLocal: false, isDefinition: true)
63 !11 = !DIGlobalVariableExpression(var: !12, expr: !DIExpression())
64 !12 = distinct !DIGlobalVariable(name: "d", scope: !0, file: !1, line: 2, type: !6, isLocal: false, isDefinition: true)
65 !13 = !{i32 2, !"Debug Info Version", i32 3}
66 !14 = !{i32 7, !"uwtable", i32 1}
67 !15 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 3, type: !16, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !18)
68 !16 = !DISubroutineType(types: !17)
71 !19 = !DILocalVariable(name: "j", scope: !15, file: !1, line: 14, type: !6)
72 !20 = !DILocalVariable(name: "k", scope: !15, file: !1, line: 14, type: !6)
73 !21 = !DILocation(line: 0, scope: !15)
79 tracksRegLiveness: true
81 - { id: 0, class: gr32 }
82 - { id: 1, class: gr32 }
83 - { id: 2, class: gr32 }
84 - { id: 3, class: gr8 }
85 - { id: 4, class: gr32 }
86 - { id: 5, class: gr32 }
87 - { id: 6, class: gr32 }
91 machineFunctionInfo: {}
94 successors: %bb.4(0x80000000)
100 successors: %bb.2(0x04000000), %bb.1(0x7c000000)
102 %2:gr32 = MOV32r0 implicit-def dead $eflags
103 %3:gr8 = COPY %2.sub_8bit
104 TEST8rr %3, %3, implicit-def $eflags
105 JCC_1 %bb.1, 5, implicit $eflags
109 successors: %bb.3(0x783e0f0f), %bb.5(0x07c1f0f1)
111 DBG_VALUE_LIST !19, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_LLVM_arg, 2, DW_OP_and, DW_OP_or, DW_OP_stack_value), %0, 1, %0, debug-location !21
112 DBG_VALUE %0, $noreg, !20, !DIExpression(), debug-location !21
113 %5:gr32 = IMPLICIT_DEF
114 %4:gr32 = SUB32rr %0, killed %5, implicit-def $eflags
115 JCC_1 %bb.5, 13, implicit $eflags
119 successors: %bb.4(0x80000000)
121 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
122 CALL64pcrel32 @h, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp
123 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
124 %6:gr32 = MOV32r0 implicit-def dead $eflags
127 successors: %bb.1(0x80000000)
129 %0:gr32 = PHI %1, %bb.0, %6, %bb.3