Skip to content

Conversation

@OCHyams
Copy link
Contributor

@OCHyams OCHyams commented Dec 16, 2025

Not sure whether this comes up in practice, but I noticed a switch block I missed in #171183 and #172167

@llvmbot
Copy link
Member

llvmbot commented Dec 16, 2025

@llvm/pr-subscribers-debuginfo

Author: Orlando Cazalet-Hyams (OCHyams)

Changes

Not sure whether this comes up in practice, but I noticed a switch block I missed in #171183 and #172167


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

2 Files Affected:

  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDie.cpp (+1)
  • (added) llvm/test/DebugInfo/MIR/X86/dwarf-dump-call-target-block.mir (+70)
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index a10becb252006..cd8a2b305a0f9 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -853,6 +853,7 @@ bool DWARFAttribute::mayHaveLocationExpr(dwarf::Attribute Attr) {
   // Extensions.
   case DW_AT_GNU_call_site_value:
   case DW_AT_GNU_call_site_target:
+  case DW_AT_GNU_call_site_target_clobbered:
     return true;
   default:
     return false;
diff --git a/llvm/test/DebugInfo/MIR/X86/dwarf-dump-call-target-block.mir b/llvm/test/DebugInfo/MIR/X86/dwarf-dump-call-target-block.mir
new file mode 100644
index 0000000000000..9fbc5e5dc6857
--- /dev/null
+++ b/llvm/test/DebugInfo/MIR/X86/dwarf-dump-call-target-block.mir
@@ -0,0 +1,70 @@
+# RUN: llc %s -start-after=livedebugvalues --filetype=obj -o - | llvm-dwarfdump - -v
+
+## Contrived test: -gdwarf-3 -ggdb and hand-modified IR adding DISubprogram
+## flag DIFlagAllCallsDescribed to force call site emission using DW_FORM_block,
+## to check block form expressions are handled.
+
+# CHECK: DW_AT_GNU_call_site_target_clobbered [DW_FORM_block1] (DW_OP_breg5 RDI+0)
+
+--- |
+  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"
+
+  define dso_local void @_Z8call_memPPFvvE(ptr noundef readonly captures(none) %f) local_unnamed_addr !dbg !5 {
+  entry:
+    %0 = load ptr, ptr %f, align 8
+    call void %0(), !dbg !13
+    ret void
+  }
+
+  !llvm.dbg.cu = !{!0}
+  !llvm.module.flags = !{!2, !3}
+  !llvm.ident = !{!4}
+
+  !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 22.0.0git", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
+  !1 = !DIFile(filename: "test.cpp", directory: "/")
+  !2 = !{i32 7, !"Dwarf Version", i32 3}
+  !3 = !{i32 2, !"Debug Info Version", i32 3}
+  !4 = !{!"clang version 22.0.0git"}
+  !5 = distinct !DISubprogram(name: "call_mem", linkageName: "_Z8call_memPPFvvE", scope: !1, file: !1, line: 1, type: !6, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
+  !6 = !DISubroutineType(types: !7)
+  !7 = !{null, !8}
+  !8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)
+  !9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
+  !10 = !DISubroutineType(types: !11)
+  !11 = !{null}
+  !12 = !{}
+  !13 = !DILocation(line: 3, scope: !5)
+...
+---
+name:            _Z8call_memPPFvvE
+alignment:       16
+tracksRegLiveness: true
+noPhis:          true
+isSSA:           false
+noVRegs:         true
+hasFakeUses:     false
+debugInstrRef:   true
+tracksDebugUserValues: true
+liveins:
+  - { reg: '$rdi' }
+frameInfo:
+  stackSize:       8
+  offsetAdjustment: -8
+  maxAlignment:    1
+  adjustsStack:    true
+  hasCalls:        true
+  maxCallFrameSize: 0
+  isCalleeSavedInfoValid: true
+machineFunctionInfo:
+  amxProgModel:    None
+body:             |
+  bb.0.entry:
+    liveins: $rdi
+
+    frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
+    frame-setup CFI_INSTRUCTION def_cfa_offset 16
+    CALL64m killed renamable $rdi, 1, $noreg, 0, $noreg, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, debug-location !13 :: (load (s64) from %ir.f)
+    $rax = frame-destroy POP64r implicit-def $rsp, implicit $rsp
+    frame-destroy CFI_INSTRUCTION def_cfa_offset 8
+    RET64
+...

@github-actions
Copy link

github-actions bot commented Dec 16, 2025

🪟 Windows x64 Test Results

  • 128706 tests passed
  • 2823 tests skipped

✅ The build succeeded and all tests passed.

Copy link
Collaborator

@dstenb dstenb left a comment

Choose a reason for hiding this comment

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

LGTM!

@OCHyams OCHyams merged commit 1ba5afe into llvm:main Dec 17, 2025
10 checks passed
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.

3 participants