Skip to content

Conversation

@OCHyams
Copy link
Contributor

@OCHyams OCHyams commented Dec 15, 2025

Fixes assertion trip introduced in #172167

See https://issues.chromium.org/issues/468825583#comment2

@llvmbot
Copy link
Member

llvmbot commented Dec 15, 2025

@llvm/pr-subscribers-debuginfo

Author: Orlando Cazalet-Hyams (OCHyams)

Changes

Fixes assertion trip introduced in #172167

See https://issues.chromium.org/issues/468825583#comment2


Full diff: https://github.com/llvm/llvm-project/pull/172336.diff

2 Files Affected:

  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (+2)
  • (added) llvm/test/DebugInfo/X86/dwarf-gnu-call-target-clobbered.mir (+58)
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index d19de7f8000ec..12bbe7f4c3849 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -1293,6 +1293,8 @@ DwarfCompileUnit::getDwarf5OrGNUAttr(dwarf::Attribute Attr) const {
     return dwarf::DW_AT_GNU_all_call_sites;
   case dwarf::DW_AT_call_target:
     return dwarf::DW_AT_GNU_call_site_target;
+  case dwarf::DW_AT_call_target_clobbered:
+    return dwarf::DW_AT_GNU_call_site_target_clobbered;
   case dwarf::DW_AT_call_origin:
     return dwarf::DW_AT_abstract_origin;
   case dwarf::DW_AT_call_return_pc:
diff --git a/llvm/test/DebugInfo/X86/dwarf-gnu-call-target-clobbered.mir b/llvm/test/DebugInfo/X86/dwarf-gnu-call-target-clobbered.mir
new file mode 100644
index 0000000000000..c03829a9490bd
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/dwarf-gnu-call-target-clobbered.mir
@@ -0,0 +1,58 @@
+# RUN: llc %s -start-after=livedebugvalues -debugger-tune=gdb --filetype=obj -o - \
+# RUN: | llvm-dwarfdump -
+
+# Generated from IR crash reproducer with `llc -stop-after=livedebugvalues -simplify-mir`.
+# Check the GNU equivalent of DW_AT_call_target_clobbered is emitted without
+# hitting assertions (DWARF version 4, -debuger-tune=gdb).
+
+# CHECK: DW_GNU_AT_call_target_clobbered
+
+--- |
+  target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+  target triple = "x86_64-unknown-linux-gnu"
+
+  define void @foo(ptr %p) !dbg !5 {
+  entry:
+    %call = tail call ptr %p(i64 0)
+    ret void
+  }
+
+  !llvm.dbg.cu = !{!0}
+  !llvm.module.flags = !{!3, !4}
+
+  !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2, splitDebugInlining: false)
+  !1 = !DIFile(filename: "test.cpp", directory: ".")
+  !2 = !{}
+  !3 = !{i32 2, !"Debug Info Version", i32 3}
+  !4 = !{i32 7, !"Dwarf Version", i32 4}
+  !5 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 479, type: !6, scopeLine: 479, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2, keyInstructions: true)
+  !6 = distinct !DISubroutineType(types: !7)
+  !7 = !{null}
+...
+---
+name:            foo
+alignment:       16
+tracksRegLiveness: true
+noPhis:          true
+isSSA:           false
+noVRegs:         true
+hasFakeUses:     false
+debugInstrRef:   true
+tracksDebugUserValues: true
+liveins:
+  - { reg: '$rdi' }
+frameInfo:
+  maxAlignment:    1
+  maxCallFrameSize: 0
+  hasTailCall:     true
+  isCalleeSavedInfoValid: true
+machineFunctionInfo:
+  amxProgModel:    None
+body:             |
+  bb.0.entry:
+    liveins: $rdi
+
+    $rax = MOV64rr $rdi
+    dead $edi = XOR32rr undef $edi, undef $edi, implicit-def dead $eflags, implicit-def $rdi
+    TAILJMPr64 killed renamable $rax, csr_64, implicit $rsp, implicit $ssp, implicit $rsp, implicit $ssp, implicit $rdi
+...

Copy link
Member

@jmorse jmorse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…d.mir

Co-authored-by: Jeremy Morse <jeremy.morse@gmail.com>
@OCHyams OCHyams enabled auto-merge (squash) December 15, 2025 17:06
@OCHyams
Copy link
Contributor Author

OCHyams commented Dec 15, 2025

Has the ability to push before pre-commit completes gone away? (I've enabled auto-merge so it lands once pre-commit completes)

@@ -0,0 +1,58 @@
# RUN: llc %s -start-after=livedebugvalues -debugger-tune=gdb --filetype=obj -o - \
# RUN: | llvm-dwarfdump -
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a | FileCheck %s?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoopsy, thanks for that catch

@OCHyams OCHyams disabled auto-merge December 15, 2025 17:27
@OCHyams OCHyams enabled auto-merge (squash) December 15, 2025 17:31
@OCHyams OCHyams disabled auto-merge December 15, 2025 18:08
@OCHyams OCHyams merged commit 3e32735 into llvm:main Dec 15, 2025
10 checks passed
@zmodem
Copy link
Collaborator

zmodem commented Dec 16, 2025

Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants