xref: /llvm-project/llvm/test/DebugInfo/X86/instr-ref-sdag-empty-vreg.ll (revision da0faa0594b9df6d401d1e5686ff32766148b075)
1; RUN: llc %s -o - -stop-before=finalize-isel \
2; RUN:  -experimental-debug-variable-locations \
3; RUN: | FileCheck %s
4
5;; The multiply by zero of %width below causes %width to become unused very late
6;; in SelectionDAG. As a result, DBG_INSTR_REFs are produced that refer to a
7;; vreg that is never defined, which risks a crash. Check that we don't crash,
8;; and produce an empty variable location.
9
10; CHECK: DBG_VALUE_LIST {{.+}}, $noreg
11; CHECK: DBG_VALUE_LIST {{.+}}, $noreg, 4
12
13target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
14target triple = "x86_64-unknown-unknown"
15
16%class.Color = type { i8 }
17
18define hidden void @_Z14drawXZWideLineR4Vec3RK5Colorf(ptr %color, float %width) local_unnamed_addr !dbg !7 {
19cond.false.i:
20  br label %_ZN4Vec39normalizeEv.exit, !dbg !12
21
22_ZN4Vec39normalizeEv.exit:                        ; preds = %cond.false.i
23  call void @llvm.dbg.value(metadata float %width, metadata !11, metadata !DIExpression()), !dbg !12
24  call void @llvm.dbg.value(metadata !DIArgList(float %width, i32 4), metadata !11, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_mul, DW_OP_stack_value)), !dbg !12
25  %mul.i = fmul float %width, 0.000000e+00, !dbg !12
26  ret void, !dbg !12
27}
28
29; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
30declare void @llvm.dbg.value(metadata, metadata, metadata)
31
32!llvm.dbg.cu = !{!0}
33!llvm.module.flags = !{!3, !4, !5, !6}
34
35!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
36!1 = !DIFile(filename: "foo.cpp", directory: ".")
37!2 = !DIBasicType(name: "int", size: 8, encoding: DW_ATE_signed)
38!3 = !{i32 2, !"Dwarf Version", i32 4}
39!4 = !{i32 2, !"Debug Info Version", i32 3}
40!5 = !{i32 1, !"wchar_size", i32 2}
41!6 = !{i32 7, !"PIC Level", i32 2}
42!7 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 6, type: !8, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)
43!8 = !DISubroutineType(types: !9)
44!9 = !{!2, !2}
45!10 = !{!11}
46!11 = !DILocalVariable(name: "baz", scope: !7, file: !1, line: 7, type: !2)
47!12 = !DILocation(line: 10, scope: !7)
48