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 deleted. This behaviour is tested
5 # for DBG_VALUE users, and DBG_VALUE_LISTs that use the value multiple times.
9 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
10 target triple = "x86_64-unknown-linux-gnu"
12 define dso_local void @main() local_unnamed_addr #0 !dbg !15 {
16 L: ; preds = %L, %L.outer
17 %tobool2.not = icmp eq i32 undef, 0
18 br i1 %tobool2.not, label %if.end4, label %L
21 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
22 %cmp = icmp slt i32 %f.0.ph, undef
23 br i1 %cmp, label %if.then5, label %if.end6
25 if.then5: ; preds = %if.end4
29 L.outer: ; preds = %if.then5, %entry
30 %f.0.ph = phi i32 [ 0, %if.then5 ], [ 1, %entry ]
33 if.end6: ; preds = %if.end4
37 declare dso_local void @h() local_unnamed_addr
39 declare void @llvm.dbg.value(metadata, metadata, metadata)
42 !llvm.module.flags = !{!13, !14}
44 !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)
45 !1 = !DIFile(filename: "tail-dup-debugvalue.c", directory: "/tmp")
47 !3 = !{!4, !7, !9, !11}
48 !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())
49 !5 = distinct !DIGlobalVariable(name: "a", scope: !0, file: !1, line: 2, type: !6, isLocal: false, isDefinition: true)
50 !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
51 !7 = !DIGlobalVariableExpression(var: !8, expr: !DIExpression())
52 !8 = distinct !DIGlobalVariable(name: "b", scope: !0, file: !1, line: 2, type: !6, isLocal: false, isDefinition: true)
53 !9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression())
54 !10 = distinct !DIGlobalVariable(name: "c", scope: !0, file: !1, line: 2, type: !6, isLocal: false, isDefinition: true)
55 !11 = !DIGlobalVariableExpression(var: !12, expr: !DIExpression())
56 !12 = distinct !DIGlobalVariable(name: "d", scope: !0, file: !1, line: 2, type: !6, isLocal: false, isDefinition: true)
57 !13 = !{i32 2, !"Debug Info Version", i32 3}
58 !14 = !{i32 7, !"uwtable", i32 1}
59 !15 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 3, type: !16, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !18)
60 !16 = !DISubroutineType(types: !17)
63 !19 = !DILocalVariable(name: "j", scope: !15, file: !1, line: 14, type: !6)
64 !20 = !DILocalVariable(name: "k", scope: !15, file: !1, line: 14, type: !6)
65 !21 = !DILocation(line: 0, scope: !15)
71 tracksRegLiveness: true
73 - { id: 0, class: gr32 }
74 - { id: 1, class: gr32 }
75 - { id: 2, class: gr32 }
76 - { id: 3, class: gr8 }
77 - { id: 4, class: gr32 }
78 - { id: 5, class: gr32 }
79 - { id: 6, class: gr32 }
83 machineFunctionInfo: {}
86 successors: %bb.4(0x80000000)
92 successors: %bb.2(0x04000000), %bb.1(0x7c000000)
94 %2:gr32 = MOV32r0 implicit-def dead $eflags
95 %3:gr8 = COPY %2.sub_8bit
96 TEST8rr %3, %3, implicit-def $eflags
97 JCC_1 %bb.1, 5, implicit $eflags
101 successors: %bb.3(0x783e0f0f), %bb.5(0x07c1f0f1)
103 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
104 DBG_VALUE %0, $noreg, !20, !DIExpression(), debug-location !21
105 %5:gr32 = IMPLICIT_DEF
106 %4:gr32 = SUB32rr %0, killed %5, implicit-def $eflags
107 JCC_1 %bb.5, 13, implicit $eflags
111 successors: %bb.4(0x80000000)
113 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
114 CALL64pcrel32 @h, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp
115 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
116 %6:gr32 = MOV32r0 implicit-def dead $eflags
119 successors: %bb.1(0x80000000)
121 %0:gr32 = PHI %1, %bb.0, %6, %bb.3