104 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 32; RUN: llc -mtriple=x86_64 %s -start-before=x86-isel -o - -stop-after=x86-isel | FileCheck %s3 4; Verify that we don't crash due to attempting to turn the indirect debug value5; in @test_non_constant variadic when salvaging the ADD node with non-constant6; RHS (originating from the GEP). This means that the debug location is7; dropped.8;9; We should salvage the debug information in @test_constant.10; XXX: Is it actually correct to add a stack_value operation in that case?11 12%struct.x = type { i64, i64, float, i64, double, ptr }13 14define i64 @test_constant(ptr %rdata) {15 ; CHECK-LABEL: name: test_constant16 ; CHECK: bb.0.entry:17 ; CHECK-NEXT: successors: %bb.1(0x80000000)18 ; CHECK-NEXT: liveins: $rdi19 ; CHECK-NEXT: {{ $}}20 ; CHECK-NEXT: DBG_PHI $rdi, 121 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gr64 = COPY $rdi22 ; CHECK-NEXT: {{ $}}23 ; CHECK-NEXT: bb.1.for.body31:24 ; CHECK-NEXT: successors: %bb.2(0x04000000), %bb.1(0x7c000000)25 ; CHECK-NEXT: {{ $}}26 ; CHECK-NEXT: DBG_INSTR_REF !4, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 144, DW_OP_deref, DW_OP_stack_value), dbg-instr-ref(1, 0), debug-location !827 ; CHECK-NEXT: CMP64mi32 [[COPY]], 1, $noreg, 144, $noreg, 0, implicit-def $eflags :: (load (s64) from %ir.arrayidx33, align 1)28 ; CHECK-NEXT: JCC_1 %bb.1, 5, implicit $eflags29 ; CHECK-NEXT: JMP_1 %bb.230 ; CHECK-NEXT: {{ $}}31 ; CHECK-NEXT: bb.2.land.lhs.true.i:32 ; CHECK-NEXT: [[MOV32r0_:%[0-9]+]]:gr32 = MOV32r0 implicit-def dead $eflags33 ; CHECK-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gr64 = SUBREG_TO_REG 0, killed [[MOV32r0_]], %subreg.sub_32bit34 ; CHECK-NEXT: $rax = COPY [[SUBREG_TO_REG]]35 ; CHECK-NEXT: RET 0, $rax36entry:37 br label %for.body3138 39for.body31: ; preds = %for.body31, %entry40 %arrayidx33 = getelementptr [30 x %struct.x], ptr %rdata, i64 0, i64 341 call void @llvm.dbg.declare(metadata ptr %arrayidx33, metadata !9, metadata !DIExpression()), !dbg !1142 %0 = load i64, ptr %arrayidx33, align 143 %cmp.i = icmp eq i64 %0, 044 br i1 %cmp.i, label %land.lhs.true.i, label %for.body3145 46land.lhs.true.i: ; preds = %for.body3147 ret i64 048}49 50define i64 @test_non_constant(ptr %rdata, i64 %i.194) {51 ; CHECK-LABEL: name: test_non_constant52 ; CHECK: bb.0.entry:53 ; CHECK-NEXT: successors: %bb.1(0x80000000)54 ; CHECK-NEXT: liveins: $rdi, $rsi55 ; CHECK-NEXT: {{ $}}56 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gr64_nosp = COPY $rsi57 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gr64 = COPY $rdi58 ; CHECK-NEXT: {{ $}}59 ; CHECK-NEXT: bb.1.for.body31:60 ; CHECK-NEXT: successors: %bb.2(0x04000000), %bb.1(0x7c000000)61 ; CHECK-NEXT: {{ $}}62 ; CHECK-NEXT: [[LEA64r:%[0-9]+]]:gr64 = LEA64r [[COPY]], 2, [[COPY]], 0, $noreg63 ; CHECK-NEXT: [[SHL64ri:%[0-9]+]]:gr64_nosp = SHL64ri [[LEA64r]], 4, implicit-def dead $eflags64 ; CHECK-NEXT: CMP64mi32 [[COPY1]], 1, killed [[SHL64ri]], 0, $noreg, 0, implicit-def $eflags :: (load (s64) from %ir.arrayidx33, align 1)65 ; CHECK-NEXT: JCC_1 %bb.1, 5, implicit $eflags66 ; CHECK-NEXT: JMP_1 %bb.267 ; CHECK-NEXT: {{ $}}68 ; CHECK-NEXT: bb.2.land.lhs.true.i:69 ; CHECK-NEXT: [[MOV32r0_:%[0-9]+]]:gr32 = MOV32r0 implicit-def dead $eflags70 ; CHECK-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gr64 = SUBREG_TO_REG 0, killed [[MOV32r0_]], %subreg.sub_32bit71 ; CHECK-NEXT: $rax = COPY [[SUBREG_TO_REG]]72 ; CHECK-NEXT: RET 0, $rax73entry:74 br label %for.body3175 76for.body31: ; preds = %for.body31, %entry77 %arrayidx33 = getelementptr [30 x %struct.x], ptr %rdata, i64 0, i64 %i.19478 call void @llvm.dbg.declare(metadata ptr %arrayidx33, metadata !4, metadata !DIExpression()), !dbg !879 %0 = load i64, ptr %arrayidx33, align 180 %cmp.i = icmp eq i64 %0, 081 br i1 %cmp.i, label %land.lhs.true.i, label %for.body3182 83land.lhs.true.i: ; preds = %for.body3184 ret i64 085}86 87declare void @llvm.dbg.declare(metadata, metadata, metadata)88 89!llvm.dbg.cu = !{!0}90!llvm.module.flags = !{!3}91 92!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !2, globals: !2, splitDebugInlining: false, nameTableKind: None)93!1 = !DIFile(filename: "foo.c", directory: "/tmp")94!2 = !{}95!3 = !{i32 2, !"Debug Info Version", i32 3}96!4 = !DILocalVariable(name: "a", arg: 1, scope: !5, file: !1, line: 33, type: !7)97!5 = distinct !DISubprogram(name: "test_non_constant", scope: !1, file: !1, line: 33, type: !6, scopeLine: 34, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)98!6 = distinct !DISubroutineType(types: !2)99!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "x", file: !1, line: 17, size: 160, elements: !2)100!8 = !DILocation(line: 33, column: 16, scope: !5)101!9 = !DILocalVariable(name: "a", arg: 1, scope: !10, file: !1, line: 33, type: !7)102!10 = distinct !DISubprogram(name: "test_constant", scope: !1, file: !1, line: 33, type: !6, scopeLine: 34, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)103!11 = !DILocation(line: 33, column: 16, scope: !10)104