From d73e3a7cb9528b0dc890dd7cfb7689f1a182e207 Mon Sep 17 00:00:00 2001 From: "Pirog, Mikolaj Maciej" Date: Thu, 25 Sep 2025 13:09:34 +0200 Subject: [PATCH 1/3] Use useDebugInstrRef instead of shouldUseDebugInstrRef --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index e61558c59bf0d..214edfc7c07f3 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -566,7 +566,7 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) { SwiftError->setFunction(mf); const Function &Fn = mf.getFunction(); - bool InstrRef = mf.shouldUseDebugInstrRef(); + bool InstrRef = mf.useDebugInstrRef(); FuncInfo->set(MF->getFunction(), *MF, CurDAG); From fb7dd26e8d13fa62e06cbec18a1c96b744abb51a Mon Sep 17 00:00:00 2001 From: "Pirog, Mikolaj Maciej" Date: Tue, 7 Oct 2025 10:42:38 +0200 Subject: [PATCH 2/3] Add test --- .../DebugInfo/X86/instr-ref-opt-bisect2.ll | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 llvm/test/DebugInfo/X86/instr-ref-opt-bisect2.ll diff --git a/llvm/test/DebugInfo/X86/instr-ref-opt-bisect2.ll b/llvm/test/DebugInfo/X86/instr-ref-opt-bisect2.ll new file mode 100644 index 0000000000000..5050f810466cc --- /dev/null +++ b/llvm/test/DebugInfo/X86/instr-ref-opt-bisect2.ll @@ -0,0 +1,37 @@ +; RUN: llc %s -o - -stop-after=livedebugvalues -opt-bisect-limit=1 | FileCheck %s +; RUN: llc %s -o - -stop-after=livedebugvalues -opt-bisect-limit=10 | FileCheck %s +; RUN: llc %s -o - -stop-after=livedebugvalues -opt-bisect-limit=100 | FileCheck %s + +; RUN: llc %s -o - -stop-after=livedebugvalues -opt-bisect-limit=1 -fast-isel=true | FileCheck %s +; RUN: llc %s -o - -stop-after=livedebugvalues -opt-bisect-limit=10 -fast-isel=true | FileCheck %s +; RUN: llc %s -o - -stop-after=livedebugvalues -opt-bisect-limit=100 -fast-isel=true | FileCheck %s + +; This test has the same purpose as the instr-ref-opt-bisect.ll, to check if +; during opt-bisect's optimisation level change we won't run into an assert. +; This is simply testing different IR. + +; CHECK: DBG_VALUE + +target triple = "x86_64-pc-windows-msvc" + +define i1 @foo(i32 %arg) !dbg !3 { +entry: + #dbg_value(i32 %arg, !4, !DIExpression(), !5) + switch i32 %arg, label %bb [ + i32 810, label %bb + ], !dbg !5 +bb: + %a = load volatile i1, ptr null, align 1 + ret i1 false +} + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!2} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, emissionKind: FullDebug) +!1 = !DIFile(filename: "instr-ref-opt-bisect2.ll", directory: ".") +!2 = !{i32 2, !"Debug Info Version", i32 3} +!3 = distinct !DISubprogram(name: "instr-ref-opt-bisect2", file: !1, unit: !0) +!4 = !DILocalVariable(name: "arg", arg: 2, scope: !3) +!5 = !DILocation(line: 0, scope: !3) + From 57c39f4a00e32aa2b63358e5835d06c9e6fa208d Mon Sep 17 00:00:00 2001 From: "Pirog, Mikolaj Maciej" Date: Wed, 8 Oct 2025 15:34:41 +0200 Subject: [PATCH 3/3] Fix test --- llvm/test/DebugInfo/X86/instr-ref-opt-bisect2.ll | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/llvm/test/DebugInfo/X86/instr-ref-opt-bisect2.ll b/llvm/test/DebugInfo/X86/instr-ref-opt-bisect2.ll index 5050f810466cc..92aedfea9449a 100644 --- a/llvm/test/DebugInfo/X86/instr-ref-opt-bisect2.ll +++ b/llvm/test/DebugInfo/X86/instr-ref-opt-bisect2.ll @@ -28,10 +28,9 @@ bb: !llvm.dbg.cu = !{!0} !llvm.module.flags = !{!2} -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, emissionKind: FullDebug) +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1) !1 = !DIFile(filename: "instr-ref-opt-bisect2.ll", directory: ".") !2 = !{i32 2, !"Debug Info Version", i32 3} -!3 = distinct !DISubprogram(name: "instr-ref-opt-bisect2", file: !1, unit: !0) +!3 = distinct !DISubprogram(name: "instr-ref-opt-bisect2", file: !1, unit: !0) !4 = !DILocalVariable(name: "arg", arg: 2, scope: !3) !5 = !DILocation(line: 0, scope: !3) -