Author: Qinkun Bao Date: 2026-02-07T11:15:49-05:00 New Revision: e3c5bf840b4b7987c70f00dadefba2df6490d1f3
URL: https://github.com/llvm/llvm-project/commit/e3c5bf840b4b7987c70f00dadefba2df6490d1f3 DIFF: https://github.com/llvm/llvm-project/commit/e3c5bf840b4b7987c70f00dadefba2df6490d1f3.diff LOG: Revert "[SelectionDAG] Fix null pointer dereference in resolveDanglingDebugIn…" This reverts commit 9e8caa78349f21ba6f27e718d7f8461c8dcfd809. Added: Modified: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Removed: llvm/test/CodeGen/X86/selectiondag-dbgvalue-null-crash.ll ################################################################################ diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 3beea7221fefe..78b725f1455cc 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1505,6 +1505,7 @@ void SelectionDAGBuilder::resolveDanglingDebugInfo(const Value *V, DanglingDebugInfoVector &DDIV = DanglingDbgInfoIt->second; for (auto &DDI : DDIV) { DebugLoc DL = DDI.getDebugLoc(); + unsigned ValSDNodeOrder = Val.getNode()->getIROrder(); unsigned DbgSDNodeOrder = DDI.getSDNodeOrder(); DILocalVariable *Variable = DDI.getVariable(); DIExpression *Expr = DDI.getExpression(); @@ -1518,7 +1519,6 @@ void SelectionDAGBuilder::resolveDanglingDebugInfo(const Value *V, // in the first place we should not be more successful here). Unless we // have some test case that prove this to be correct we should avoid // calling EmitFuncArgumentDbgValue here. - unsigned ValSDNodeOrder = Val.getNode()->getIROrder(); if (!EmitFuncArgumentDbgValue(V, Variable, Expr, DL, FuncArgumentDbgValueKind::Value, Val)) { LLVM_DEBUG(dbgs() << "Resolve dangling debug info for " diff --git a/llvm/test/CodeGen/X86/selectiondag-dbgvalue-null-crash.ll b/llvm/test/CodeGen/X86/selectiondag-dbgvalue-null-crash.ll deleted file mode 100644 index 99e0bd6ee3f23..0000000000000 --- a/llvm/test/CodeGen/X86/selectiondag-dbgvalue-null-crash.ll +++ /dev/null @@ -1,46 +0,0 @@ -; Test that the code generation works correctly on Linux -; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s -; Darwin currently crashes due to an unrelated DWARF generation bug -; RUN: not --crash llc < %s -mtriple=x86_64-apple-darwin - -; Regression test for SelectionDAG::resolveDanglingDebugInfo crash when -; handling aggregate types with nested empty structs. -; -; This test verifies the fix for null pointer dereference in -; SelectionDAG::resolveDanglingDebugInfo. The original issue occurred when -; insertvalue operations on aggregate types containing nested empty structs -; produced SDValue nodes with null pointers. -; -; NOTE: This test case also revealed an unrelated Darwin-specific crash in -; DwarfCompileUnit::constructSubprogramScopeDIE during DWARF generation. -; -; FIXME: Investigate and fix the Darwin crash separately. The crash occurs in -; the Assembly Printer pass when generating DWARF debug info for -; functions with aggregate types containing nested empty structs. - -; CHECK-LABEL: test_empty_struct_debug: -; CHECK: retq - -define void @test_empty_struct_debug() !dbg !4 { -entry: - %tmp = alloca { { i1, {} }, ptr, { { {} }, { {} } }, i64 }, align 8 - #dbg_value({ { {} }, { {} } } zeroinitializer, !5, !DIExpression(), !6) - #dbg_value(i64 2, !7, !DIExpression(), !6) - %0 = insertvalue { { i1, {} }, ptr, { { {} }, { {} } }, i64 } { { i1, {} } zeroinitializer, ptr null, { { {} }, { {} } } zeroinitializer, i64 2 }, ptr null, 1, !dbg !6 - %1 = insertvalue { { i1, {} }, ptr, { { {} }, { {} } }, i64 } %0, { i1, {} } zeroinitializer, 0, !dbg !8 - store { { i1, {} }, ptr, { { {} }, { {} } }, i64 } %1, ptr %tmp, align 8 - ret void -} - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!2, !3} - -!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly) -!1 = !DIFile(filename: "test_selectiondag.cpp", directory: "/home/AnonTokyo/documents/llvm-project/temp") -!2 = !{i32 2, !"Debug Info Version", i32 3} -!3 = !{i32 2, !"Dwarf Version", i32 4} -!4 = distinct !DISubprogram(name: "test_empty_struct_debug", scope: !1, file: !1, line: 1, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0) -!5 = !DILocalVariable(name: "v1", scope: !4, file: !1, line: 2) -!6 = !DILocation(line: 2, column: 1, scope: !4) -!7 = !DILocalVariable(name: "v2", scope: !4, file: !1, line: 3) -!8 = !DILocation(line: 3, column: 1, scope: !4) _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
