Skip to content

Revert "[clang][DebugInfo] Add virtuality call-site target informatio…#182343

Merged
ilovepi merged 1 commit intollvm:mainfrom
ilovepi:fix-debuginfo
Feb 19, 2026
Merged

Revert "[clang][DebugInfo] Add virtuality call-site target informatio…#182343
ilovepi merged 1 commit intollvm:mainfrom
ilovepi:fix-debuginfo

Conversation

@ilovepi
Copy link
Contributor

@ilovepi ilovepi commented Feb 19, 2026

…n in DWARF. (#167666)"

This reverts commit 418ba6e.

The commit caused an ICE due to hitting unreachable in llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:1307

Fixes #182337

…n in DWARF. (llvm#167666)"

This reverts commit 418ba6e.

The commit caused an ICE due to hitting unreachable in
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:1307

Fixes llvm#182337
@llvmbot
Copy link
Member

llvmbot commented Feb 19, 2026

@llvm/pr-subscribers-llvm-selectiondag
@llvm/pr-subscribers-llvm-ir
@llvm/pr-subscribers-debuginfo
@llvm/pr-subscribers-llvm-binary-utilities
@llvm/pr-subscribers-backend-mips
@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-backend-aarch64

Author: Paul Kirth (ilovepi)

Changes

…n in DWARF. (#167666)"

This reverts commit 418ba6e.

The commit caused an ICE due to hitting unreachable in llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:1307

Fixes #182337


Patch is 29.02 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/182343.diff

24 Files Affected:

  • (modified) clang/lib/CodeGen/CGCall.cpp (-2)
  • (modified) clang/lib/CodeGen/CGDebugInfo.cpp (-17)
  • (modified) clang/lib/CodeGen/CGDebugInfo.h (-9)
  • (removed) clang/test/DebugInfo/CXX/callsite-base.cpp (-48)
  • (removed) clang/test/DebugInfo/CXX/callsite-derived.cpp (-58)
  • (removed) clang/test/DebugInfo/CXX/callsite-edges.cpp (-93)
  • (removed) cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/callsite-dwarf.cpp (-72)
  • (modified) llvm/include/llvm/BinaryFormat/Dwarf.def (-1)
  • (modified) llvm/include/llvm/CodeGen/MachineFunction.h (-6)
  • (modified) llvm/include/llvm/CodeGen/TargetLowering.h (-4)
  • (modified) llvm/include/llvm/IR/FixedMetadataKinds.def (-1)
  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (+5-10)
  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h (-4)
  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (+1-28)
  • (modified) llvm/lib/CodeGen/MIRPrinter.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/MachineFunction.cpp (-3)
  • (modified) llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp (-14)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDie.cpp (+1-2)
  • (modified) llvm/lib/Target/AArch64/AArch64ISelLowering.cpp (+2-1)
  • (modified) llvm/lib/Target/ARM/ARMISelLowering.cpp (+2-1)
  • (modified) llvm/lib/Target/Mips/MipsISelLowering.cpp (+2-1)
  • (modified) llvm/lib/Target/RISCV/RISCVISelLowering.cpp (+2-1)
  • (modified) llvm/lib/Target/X86/X86ISelLoweringCall.cpp (+2-1)
  • (modified) llvm/test/CodeGen/MIR/X86/callsite-emit-calleetypeid.ll (+5-3)
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 1d8ea9a3216a1..224b2997b7db4 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -6322,8 +6322,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
       DI->EmitFuncDeclForCallSite(
           CI, DI->getFunctionType(CalleeDecl, ResTy, Args), CalleeGlobalDecl);
     }
-    // Generate call site target information.
-    DI->addCallTargetIfVirtual(CalleeDecl, CI);
   }
 
   return Ret;
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index ab97b3136e5af..5e452245ee627 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4978,23 +4978,6 @@ void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
     Fn->setSubprogram(SP);
 }
 
-void CGDebugInfo::addCallTargetIfVirtual(const FunctionDecl *FD,
-                                         llvm::CallBase *CI) {
-  if (!shouldGenerateVirtualCallSite())
-    return;
-
-  if (!FD)
-    return;
-
-  assert(CI && "Invalid Call Instruction.");
-  if (!CI->isIndirectCall())
-    return;
-
-  // Always get the method declaration.
-  if (llvm::DISubprogram *MD = getFunctionDeclaration(FD))
-    CI->setMetadata(llvm::LLVMContext::MD_call_target, MD);
-}
-
 void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
                                           QualType CalleeType,
                                           GlobalDecl CalleeGlobalDecl) {
diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 9216ac6a0ac2c..31b40f06f09d0 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -682,9 +682,6 @@ class CGDebugInfo {
   /// that it is supported and enabled.
   llvm::DINode::DIFlags getCallSiteRelatedAttrs() const;
 
-  /// Add call target information.
-  void addCallTargetIfVirtual(const FunctionDecl *FD, llvm::CallBase *CI);
-
 private:
   /// Amend \p I's DebugLoc with \p Group (its source atom group) and \p
   /// Rank (lower nonzero rank is higher precedence). Does nothing if \p I
@@ -909,12 +906,6 @@ class CGDebugInfo {
   /// If one exists, returns the linkage name of the specified \
   /// (non-null) \c Method. Returns empty string otherwise.
   llvm::StringRef GetMethodLinkageName(const CXXMethodDecl *Method) const;
-
-  /// Returns true if we should generate call target information.
-  bool shouldGenerateVirtualCallSite() const {
-    // Check general conditions for call site generation.
-    return (getCallSiteRelatedAttrs() != llvm::DINode::FlagZero);
-  }
 };
 
 /// A scoped helper to set the current debug location to the specified
diff --git a/clang/test/DebugInfo/CXX/callsite-base.cpp b/clang/test/DebugInfo/CXX/callsite-base.cpp
deleted file mode 100644
index cf26d62a03c0b..0000000000000
--- a/clang/test/DebugInfo/CXX/callsite-base.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-// RUN: %clang_cc1 -triple=x86_64-linux -disable-llvm-passes -emit-llvm \
-// RUN:            -debug-info-kind=standalone -dwarf-version=5 -O1 %s \
-// RUN: -o - | FileCheck %s -check-prefix CHECK-BASE
-
-// Simple class with only virtual methods: inlined and not-inlined
-//
-// The following three scenarios are considered:
-// - out-of-line defined virtual member function (f1)
-// - declared-but-not-defined virtual member function (f2)
-// - inline defined virtual member function (f3)
-//
-// 1) We check for a generated 'call_target' for: 'f1', 'f2' and 'f3'.
-// 2) Check that the 'CBase' type is defined.
-
-struct CBase {
-  virtual void f1();
-  virtual void f2();
-  virtual void f3() {}
-};
-void CBase::f1() {}
-
-void bar(CBase *Base) {
-  Base->f1();
-  Base->f2();
-  Base->f3();
-
-  // Because this will instantiate the ctor, the CBase type should be defined.
-  CBase B;
-  B.f1();
-}
-
-// CHECK-BASE: %struct.CBase = type { ptr }
-
-// CHECK-BASE: define {{.*}} @_Z3barP5CBase{{.*}} {
-// CHECK-BASE:   alloca %struct.CBase
-// CHECK-BASE:   call void %1{{.*}} !dbg {{![0-9]+}}, !call_target [[BASE_F1_DCL:![0-9]+]]
-// CHECK-BASE:   call void %3{{.*}} !dbg {{![0-9]+}}, !call_target [[BASE_F2_DCL:![0-9]+]]
-// CHECK-BASE:   call void %5{{.*}} !dbg {{![0-9]+}}, !call_target [[BASE_F3_DCL:![0-9]+]]
-// CHECK-BASE:   call void @_ZN5CBaseC1Ev{{.*}} !dbg {{![0-9]+}}
-// CHECK-BASE:   call void @_ZN5CBase2f1Ev{{.*}} !dbg {{![0-9]+}}
-// CHECK-BASE: }
-
-// CHECK-BASE: [[BASE_F1_DCL]] = {{.*}}!DISubprogram(name: "f1", linkageName: "_ZN5CBase2f1Ev", {{.*}}containingType
-// CHECK-BASE: [[BASE_F2_DCL]] = {{.*}}!DISubprogram(name: "f2", linkageName: "_ZN5CBase2f2Ev", {{.*}}containingType
-// CHECK-BASE: [[BASE_F3_DCL]] = {{.*}}!DISubprogram(name: "f3", linkageName: "_ZN5CBase2f3Ev", {{.*}}containingType
-
-// CHECK-BASE: [[BASE_F1_DEF:![0-9]+]] = {{.*}}!DISubprogram(name: "f1", linkageName: "_ZN5CBase2f1Ev", {{.*}}DISPFlagDefinition
-// CHECK-BASE: [[BASE_F3_DEF:![0-9]+]] = {{.*}}!DISubprogram(name: "f3", linkageName: "_ZN5CBase2f3Ev", {{.*}}DISPFlagDefinition
diff --git a/clang/test/DebugInfo/CXX/callsite-derived.cpp b/clang/test/DebugInfo/CXX/callsite-derived.cpp
deleted file mode 100644
index 3338290bdd829..0000000000000
--- a/clang/test/DebugInfo/CXX/callsite-derived.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-// RUN: %clang_cc1 -triple=x86_64-linux -disable-llvm-passes -emit-llvm \
-// RUN:            -debug-info-kind=constructor -dwarf-version=5 -O1 %s \
-// RUN:            -o - | FileCheck %s -check-prefix CHECK-DERIVED
-
-// Simple base and derived class with virtual and static methods:
-// We check for:
-// - a generated 'call_target' for 'f1'.
-// - not generated 'call_target' for 'f3'.
-
-struct CBase {
-  virtual void f1() {}
-  static void f3();
-};
-
-void CBase::f3() {
-}
-
-void foo(CBase *Base) {
-  CBase::f3();
-}
-
-struct CDerived : public CBase {
-  void f1() {}
-};
-void foo(CDerived *Derived);
-
-int main() {
-  CDerived D;
-  foo(&D);
-
-  return 0;
-}
-
-void foo(CDerived *Derived) {
-  Derived->f1();
-}
-
-// CHECK-DERIVED: define {{.*}} @_Z3fooP5CBase{{.*}} {
-// CHECK-DERIVED: call void @_ZN5CBase2f3Ev{{.*}} !dbg {{![0-9]+}}
-// CHECK-DERIVED: }
-
-// CHECK-DERIVED: define {{.*}} @main{{.*}} {
-// CHECK-DERIVED:  call void @_ZN8CDerivedC1Ev{{.*}} !dbg {{![0-9]+}}
-// CHECK-DERIVED:  call void @_Z3fooP8CDerived{{.*}} !dbg {{![0-9]+}}
-// CHECK-DERIVED: }
-
-// CHECK-DERIVED: define {{.*}} @_ZN8CDerivedC1Ev{{.*}} {
-// CHECK-DERIVED:  call void @_ZN8CDerivedC2Ev{{.*}} !dbg {{![0-9]+}}
-// CHECK-DERIVED: }
-
-// CHECK-DERIVED: define {{.*}} @_Z3fooP8CDerived{{.*}} {
-// CHECK-DERIVED:  call void %1{{.*}} !dbg {{![0-9]+}}, !call_target [[DERIVED_F1_DCL:![0-9]+]]
-// CHECK-DERIVED: }
-
-// CHECK-DERIVED: [[BASE_F1_DCL:![0-9]+]] = {{.*}}!DISubprogram(name: "f1", linkageName: "_ZN5CBase2f1Ev", {{.*}}containingType
-// CHECK-DERIVED: [[DERIVED_F1_DCL]] = {{.*}}!DISubprogram(name: "f1", linkageName: "_ZN8CDerived2f1Ev", {{.*}}containingType
-// CHECK-DERIVED: [[DERIVED_F1_DEF:![0-9]+]] = {{.*}}!DISubprogram(name: "f1", linkageName: "_ZN8CDerived2f1Ev", {{.*}}DISPFlagDefinition
-// CHECK-DERIVED: [[BASE_F1_DEF:![0-9]+]] = {{.*}}!DISubprogram(name: "f1", linkageName: "_ZN5CBase2f1Ev", {{.*}}DISPFlagDefinition
diff --git a/clang/test/DebugInfo/CXX/callsite-edges.cpp b/clang/test/DebugInfo/CXX/callsite-edges.cpp
deleted file mode 100644
index 812cfc1fb4cf2..0000000000000
--- a/clang/test/DebugInfo/CXX/callsite-edges.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-// RUN: %clang_cc1 -triple=x86_64-linux -disable-llvm-passes -emit-llvm \
-// RUN:            -debug-info-kind=constructor -dwarf-version=5 -O1 %s \
-// RUN:            -o - | FileCheck %s -check-prefix CHECK-EDGES
-
-// The following are identified edge cases involving the method being called:
-// 1) Method is declared but not defined in current CU.
-// 2) Pure virtual method but not defined in current CU.
-// 3) Virtual method defined in a deeply nested structure hierarchy.
-
-//---------------------------------------------------------------------
-// 1) Method is declared but not defined in current CU - Pass.
-//    Generate 'call_target' metadata for 'f1' and 'f2'.
-//---------------------------------------------------------------------
-struct CEmpty {
-  virtual void f1();
-  virtual void f2();
-};
-
-void CEmpty::f2() {
-}
-
-void edge_a(CEmpty *Empty) {
-  Empty->f1();
-  Empty->f2();
-}
-
-//---------------------------------------------------------------------
-// 2) Pure virtual method but not defined in current CU - Pass.
-//    Generate 'call_target' metadata for 'f1' and 'f2'.
-//---------------------------------------------------------------------
-struct CBase {
-  virtual void f1() = 0;
-  virtual void f2();
-};
-
-void CBase::f2() {
-}
-
-void edge_b(CBase *Base) {
-  Base->f1();
-  Base->f2();
-}
-
-//---------------------------------------------------------------------
-// 3) Virtual method defined in a deeply nested structure hierarchy - Pass.
-//    Generate 'call_target' metadata for 'd0', 'd1', 'd2' and 'd3'.
-//---------------------------------------------------------------------
-struct CD0 {
-  struct CD1 {
-    virtual void d1();
-  };
-
-  CD1 D1;
-  virtual void d0();
-};
-
-void CD0::d0() {}
-void CD0::CD1::d1() {}
-
-void edge_c(CD0 *D0) {
-  D0->d0();
-
-  CD0::CD1 *D1 = &D0->D1;
-  D1->d1();
-}
-
-// CHECK-EDGES: define {{.*}} @_Z6edge_aP6CEmpty{{.*}} {
-// CHECK-EDGES:  call void %1{{.*}} !dbg {{![0-9]+}}, !call_target [[CEMPTY_F1_DCL:![0-9]+]]
-// CHECK-EDGES:  call void %3{{.*}} !dbg {{![0-9]+}}, !call_target [[CEMPTY_F2_DCL:![0-9]+]]
-// CHECK-EDGES: }
-
-// CHECK-EDGES: define {{.*}} @_Z6edge_bP5CBase{{.*}} {
-// CHECK-EDGES:  call void %1{{.*}} !dbg {{![0-9]+}}, !call_target [[CBASE_F1_DCL:![0-9]+]]
-// CHECK-EDGES:  call void %3{{.*}} !dbg {{![0-9]+}}, !call_target [[CBASE_F2_DCL:![0-9]+]]
-// CHECK-EDGES: }
-
-// CHECK-EDGES: define {{.*}} @_Z6edge_cP3CD0{{.*}} {
-// CHECK-EDGES:  call void %1{{.*}} !dbg {{![0-9]+}}, !call_target [[CD0_D0_DCL:![0-9]+]]
-// CHECK-EDGES:  call void %4{{.*}} !dbg {{![0-9]+}}, !call_target [[CD0_D1_DCL:![0-9]+]]
-// CHECK-EDGES: }
-
-// CHECK-EDGES:  [[CD0_D1_DCL]] = {{.*}}!DISubprogram(name: "d1", linkageName: "_ZN3CD03CD12d1Ev", {{.*}}containingType
-// CHECK-EDGES:  [[CD0_D0_DCL]] = {{.*}}!DISubprogram(name: "d0", linkageName: "_ZN3CD02d0Ev", {{.*}}containingType
-
-// CHECK-EDGES:  [[CBASE_F1_DCL]] = {{.*}}!DISubprogram(name: "f1", linkageName: "_ZN5CBase2f1Ev", {{.*}}containingType
-// CHECK-EDGES:  [[CBASE_F2_DCL]] = {{.*}}!DISubprogram(name: "f2", linkageName: "_ZN5CBase2f2Ev", {{.*}}containingType
-// CHECK-EDGES:  [[CEMPTY_F2_DEF:![0-9]+]] = {{.*}}!DISubprogram(name: "f2", linkageName: "_ZN6CEmpty2f2Ev", {{.*}}DISPFlagDefinition
-// CHECK-EDGES:  [[CEMPTY_F2_DCL]] = {{.*}}!DISubprogram(name: "f2", linkageName: "_ZN6CEmpty2f2Ev", {{.*}}containingType
-// CHECK-EDGES:  [[CEMPTY_F1_DCL]] = {{.*}}!DISubprogram(name: "f1", linkageName: "_ZN6CEmpty2f1Ev", {{.*}}containingType
-// CHECK-EDGES:  [[CBASE_F2_DEF:![0-9]+]] = {{.*}}!DISubprogram(name: "f2", linkageName: "_ZN5CBase2f2Ev", {{.*}}DISPFlagDefinition
-
-// CHECK-EDGES:  [[CD0_D0_DEF:![0-9]+]] = {{.*}}!DISubprogram(name: "d0", linkageName: "_ZN3CD02d0Ev", {{.*}}DISPFlagDefinition
-// CHECK-EDGES:  [[CD0_D1_DEF:![0-9]+]] = {{.*}}!DISubprogram(name: "d1", linkageName: "_ZN3CD03CD12d1Ev", {{.*}}DISPFlagDefinition
diff --git a/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/callsite-dwarf.cpp b/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/callsite-dwarf.cpp
deleted file mode 100644
index 8b4ddf542ddb3..0000000000000
--- a/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/callsite-dwarf.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-// REQUIRES: x86-registered-target
-// RUN: %clang --target=x86_64-linux -c -g -O1 %s -o - | \
-// RUN: llvm-dwarfdump --debug-info - | FileCheck %s --check-prefix=CHECK
-
-// Simple base and derived class with virtual:
-// We check for a generated 'DW_AT_LLVM_virtual_call_origin' for 'foo', that
-// corresponds to the 'call_target' metadata added to the indirect call
-// instruction.
-
-// Note: We should add a test case inside LLDB that make use of the
-//       virtuality call-site target information in DWARF.
-
-struct CBaseOne {
-  virtual void foo(int &);
-};
-
-struct CDerivedOne : CBaseOne {
-  void foo(int &);
-};
-
-void CDerivedOne::foo(int &) {}
-
-struct CBaseTwo {
-  CDerivedOne *DerivedOne;
-};
-
-struct CDerivedTwo : CBaseTwo {
-  void bar(int &);
-};
-
-void CDerivedTwo::bar(int &j) { DerivedOne->foo(j); }
-
-// The IR generated looks like:
-//
-// define dso_local void @_ZN11CDerivedTwo3barERi(...) !dbg !40 {
-// entry:
-//   ..
-//   %vtable = load ptr, ptr %0, align 8
-//   %vfn = getelementptr inbounds ptr, ptr %vtable, i64 0
-//   %2 = load ptr, ptr %vfn, align 8
-//   call void %2(...), !dbg !65, !call_target !25
-//   ret void
-// }
-//
-// !25 = !DISubprogram(name: "foo", linkageName: "_ZN11CDerivedOne3fooERi", ...)
-// !40 = !DISubprogram(name: "bar", linkageName: "_ZN11CDerivedTwo3barERi", ...)
-// !65 = !DILocation(line: 25, column: 15, scope: !40)
-
-// CHECK: DW_TAG_compile_unit
-// CHECK:   DW_TAG_structure_type
-// CHECK:     DW_AT_name	("CDerivedOne")
-// CHECK: [[FOO_DCL:0x[a-f0-9]+]]:    DW_TAG_subprogram
-// CHECK:       DW_AT_name	("foo")
-// CHECK:   DW_TAG_structure_type
-// CHECK:     DW_AT_name	("CBaseOne")
-// CHECK: [[FOO_DEF:0x[a-f0-9]+]]:  DW_TAG_subprogram
-// CHECK:     DW_AT_call_all_calls	(true)
-// CHECK:     DW_AT_specification	([[FOO_DCL]] "{{.*}}foo{{.*}}")
-// CHECK:   DW_TAG_structure_type
-// CHECK:     DW_AT_name	("CDerivedTwo")
-// CHECK:     DW_TAG_subprogram
-// CHECK:       DW_AT_name	("bar")
-// CHECK:   DW_TAG_structure_type
-// CHECK:     DW_AT_name	("CBaseTwo")
-// CHECK:   DW_TAG_subprogram
-// CHECK:     DW_AT_call_all_calls	(true)
-// CHECK:     DW_AT_specification	(0x{{.*}} "{{.*}}bar{{.*}}")
-// CHECK:     DW_TAG_call_site
-// CHECK:       DW_AT_call_target_clobbered	(DW_OP_reg0 RAX)
-// CHECK:       DW_AT_call_tail_call	(true)
-// CHECK:       DW_AT_call_pc	(0x{{.*}})
-// CHECK:       DW_AT_LLVM_virtual_call_origin	([[FOO_DCL]] "{{.*}}foo{{.*}}")
diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.def b/llvm/include/llvm/BinaryFormat/Dwarf.def
index 50b83884c851a..75f1061c471c6 100644
--- a/llvm/include/llvm/BinaryFormat/Dwarf.def
+++ b/llvm/include/llvm/BinaryFormat/Dwarf.def
@@ -647,7 +647,6 @@ HANDLE_DW_AT(0x3e10, LLVM_address_space, 0, LLVM)
 HANDLE_DW_AT(0x3e11, LLVM_lanes, 0, LLVM)
 HANDLE_DW_AT(0x3e12, LLVM_lane_pc, 0, LLVM)
 HANDLE_DW_AT(0x3e13, LLVM_vector_size, 0, LLVM)
-HANDLE_DW_AT(0x3e14, LLVM_virtual_call_origin, 0, LLVM)
 
 // https://llvm.org/docs/AMDGPUUsage.html#address-space-identifier
 HANDLE_DW_ASPACE(0x0, none)
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index 26b6c457a45ba..edb8963ce42b6 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -526,17 +526,11 @@ class LLVM_ABI MachineFunction {
     /// Callee type ids.
     SmallVector<ConstantInt *, 4> CalleeTypeIds;
 
-    /// 'call_target' metadata for the DISubprogram. It is the declaration
-    /// or definition of the target function and might be indirect.
-    MDNode *CallTarget = nullptr;
-
     CallSiteInfo() = default;
 
     /// Extracts the numeric type id from the CallBase's callee_type Metadata,
     /// and sets CalleeTypeIds. This is used as type id for the indirect call in
     /// the call graph section.
-    /// Extracts the MDNode from the CallBase's call_target Metadata to be used
-    /// during the construction of the debug info call site entries.
     LLVM_ABI CallSiteInfo(const CallBase &CB);
   };
 
diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h
index 39699cb19a4b7..37002d3bc227f 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -5936,10 +5936,6 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
                                        LoadSDNode *OriginalLoad,
                                        SelectionDAG &DAG) const;
 
-protected:
-  void setTypeIdForCallsiteInfo(const CallBase *CB, MachineFunction &MF,
-                                MachineFunction::CallSiteInfo &CSInfo) const;
-
 private:
   SDValue foldSetCCWithAnd(EVT VT, SDValue N0, SDValue N1, ISD::CondCode Cond,
                            const SDLoc &DL, DAGCombinerInfo &DCI) const;
diff --git a/llvm/include/llvm/IR/FixedMetadataKinds.def b/llvm/include/llvm/IR/FixedMetadataKinds.def
index 0d79677d7079e..98129985714b2 100644
--- a/llvm/include/llvm/IR/FixedMetadataKinds.def
+++ b/llvm/include/llvm/IR/FixedMetadataKinds.def
@@ -59,4 +59,3 @@ LLVM_FIXED_MD_KIND(MD_captures, "captures", 44)
 LLVM_FIXED_MD_KIND(MD_alloc_token, "alloc_token", 45)
 LLVM_FIXED_MD_KIND(MD_implicit_ref, "implicit.ref", 46)
 LLVM_FIXED_MD_KIND(MD_nofpclass, "nofpclass", 47)
-LLVM_FIXED_MD_KIND(MD_call_target, "call_target", 48)
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index eb55b47dfde2b..e87d3f3ee02a0 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -1349,7 +1349,11 @@ DIE &DwarfCompileUnit::constructCallSiteEntryDIE(
   } else if (CalleeSP) {
     DIE *CalleeDIE = getOrCreateSubprogramDIE(CalleeSP, CalleeF);
     assert(CalleeDIE && "Could not create DIE for call site entry origin");
-    addLinkageNamesToDeclarations(*DD, *CalleeSP, *CalleeDIE);
+    if (AddLinkageNamesToDeclCallOriginsForTuning(DD) &&
+        !CalleeSP->isDefinition() &&
+        !CalleeDIE->findAttribute(dwarf::DW_AT_linkage_name)) {
+      addLinkageName(*CalleeDIE, CalleeSP->getLinkageName());
+    }
 
     addDIEEntry(CallSiteDIE, getDwarf5OrGNUAttr(dwarf::DW_AT_call_origin),
                 *CalleeDIE);
@@ -1887,12 +1891,3 @@ DIE *DwarfCompileUnit::getOrCreateSubprogramDIE(const DISubprogram *SP,
 
   return DwarfUnit::getOrCreateSubprogramDIE(SP, F, Minimal);
 }
-
-void DwarfCompileUnit::addLinkageNamesToDeclarations(
-    const DwarfDebug &DD, const DISubprogram &CalleeSP, DIE &CalleeDIE) {
-  if (AddLinkageNamesToDeclCallOriginsForTuning(&DD) &&
-      !CalleeSP.isDefinition() &&
-      !CalleeDIE.findAttribute(dwarf::DW_AT_linkage_name)) {
-    addLinkageName(CalleeDIE, CalleeSP.getLinkageName());
-  }
-}
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
index ede02c169bffd..04d4556c3ce52 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
@@ -436,10 +436,6 @@ class DwarfCompileUnit final : public DwarfUnit {
   void addBaseTypeRef(DIEValueList &Die, int64_t Idx);
 
   MDNodeSetVector &getDeferredLocalDecls() { return DeferredLocalDecls; }
-
-  void addLinkageNamesToDeclarations(const DwarfDebug &DD,
-                                     const DISubprogram &CalleeSP,
-                                     DIE &CalleeDIE);
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 042c98fa1c02f..f8c2c753b91ce 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -955,30 +955,6 @@ void DwarfDebug::constructCallSiteEntryDIEs(const DISubprogram &SP,
     return true;
   };
 
-  // Create call_target connections for indirect calls.
-  auto addCallSiteTargetForIndirectCalls = [&](const MachineInstr *MI,
-                                               DIE &CallSiteDIE) {
-    const MachineFunction *MF = MI->getMF();
-    const auto &CalleesMap = MF->getCallSitesInfo();
-    auto CSInfo = CalleesMap.find(MI);
-    // Get the information for the call instruction.
-    if (CSInfo == CalleesMap.end() || !CSInfo->second.CallTarget)
-      return;
-
-    MDNode *CallTarget = CSInfo->second.CallTarget;
-    // Add DW_AT_LLVM_virtual_call_origin with the 'call_target' metadata.
-    assert(!CallSiteDIE.findAttribute(dwarf::DW_AT_LLVM_virtual_call_origin) &&
-           "DW_AT_LLVM_virtual_call_origin already exists");
-    const DISubprogram *CalleeSP = dyn_cast<DISubprogram>(CallTarget);
-    DIE *CalleeDIE = CU.getOrCreateSubprogramDIE(CalleeSP, nullptr);
-    assert(CalleeDIE &&...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Feb 19, 2026

@llvm/pr-subscribers-backend-x86

Author: Paul Kirth (ilovepi)

Changes

…n in DWARF. (#167666)"

This reverts commit 418ba6e.

The commit caused an ICE due to hitting unreachable in llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:1307

Fixes #182337


Patch is 29.02 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/182343.diff

24 Files Affected:

  • (modified) clang/lib/CodeGen/CGCall.cpp (-2)
  • (modified) clang/lib/CodeGen/CGDebugInfo.cpp (-17)
  • (modified) clang/lib/CodeGen/CGDebugInfo.h (-9)
  • (removed) clang/test/DebugInfo/CXX/callsite-base.cpp (-48)
  • (removed) clang/test/DebugInfo/CXX/callsite-derived.cpp (-58)
  • (removed) clang/test/DebugInfo/CXX/callsite-edges.cpp (-93)
  • (removed) cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/callsite-dwarf.cpp (-72)
  • (modified) llvm/include/llvm/BinaryFormat/Dwarf.def (-1)
  • (modified) llvm/include/llvm/CodeGen/MachineFunction.h (-6)
  • (modified) llvm/include/llvm/CodeGen/TargetLowering.h (-4)
  • (modified) llvm/include/llvm/IR/FixedMetadataKinds.def (-1)
  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (+5-10)
  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h (-4)
  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (+1-28)
  • (modified) llvm/lib/CodeGen/MIRPrinter.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/MachineFunction.cpp (-3)
  • (modified) llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp (-14)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDie.cpp (+1-2)
  • (modified) llvm/lib/Target/AArch64/AArch64ISelLowering.cpp (+2-1)
  • (modified) llvm/lib/Target/ARM/ARMISelLowering.cpp (+2-1)
  • (modified) llvm/lib/Target/Mips/MipsISelLowering.cpp (+2-1)
  • (modified) llvm/lib/Target/RISCV/RISCVISelLowering.cpp (+2-1)
  • (modified) llvm/lib/Target/X86/X86ISelLoweringCall.cpp (+2-1)
  • (modified) llvm/test/CodeGen/MIR/X86/callsite-emit-calleetypeid.ll (+5-3)
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 1d8ea9a3216a1..224b2997b7db4 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -6322,8 +6322,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
       DI->EmitFuncDeclForCallSite(
           CI, DI->getFunctionType(CalleeDecl, ResTy, Args), CalleeGlobalDecl);
     }
-    // Generate call site target information.
-    DI->addCallTargetIfVirtual(CalleeDecl, CI);
   }
 
   return Ret;
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index ab97b3136e5af..5e452245ee627 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4978,23 +4978,6 @@ void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
     Fn->setSubprogram(SP);
 }
 
-void CGDebugInfo::addCallTargetIfVirtual(const FunctionDecl *FD,
-                                         llvm::CallBase *CI) {
-  if (!shouldGenerateVirtualCallSite())
-    return;
-
-  if (!FD)
-    return;
-
-  assert(CI && "Invalid Call Instruction.");
-  if (!CI->isIndirectCall())
-    return;
-
-  // Always get the method declaration.
-  if (llvm::DISubprogram *MD = getFunctionDeclaration(FD))
-    CI->setMetadata(llvm::LLVMContext::MD_call_target, MD);
-}
-
 void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
                                           QualType CalleeType,
                                           GlobalDecl CalleeGlobalDecl) {
diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 9216ac6a0ac2c..31b40f06f09d0 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -682,9 +682,6 @@ class CGDebugInfo {
   /// that it is supported and enabled.
   llvm::DINode::DIFlags getCallSiteRelatedAttrs() const;
 
-  /// Add call target information.
-  void addCallTargetIfVirtual(const FunctionDecl *FD, llvm::CallBase *CI);
-
 private:
   /// Amend \p I's DebugLoc with \p Group (its source atom group) and \p
   /// Rank (lower nonzero rank is higher precedence). Does nothing if \p I
@@ -909,12 +906,6 @@ class CGDebugInfo {
   /// If one exists, returns the linkage name of the specified \
   /// (non-null) \c Method. Returns empty string otherwise.
   llvm::StringRef GetMethodLinkageName(const CXXMethodDecl *Method) const;
-
-  /// Returns true if we should generate call target information.
-  bool shouldGenerateVirtualCallSite() const {
-    // Check general conditions for call site generation.
-    return (getCallSiteRelatedAttrs() != llvm::DINode::FlagZero);
-  }
 };
 
 /// A scoped helper to set the current debug location to the specified
diff --git a/clang/test/DebugInfo/CXX/callsite-base.cpp b/clang/test/DebugInfo/CXX/callsite-base.cpp
deleted file mode 100644
index cf26d62a03c0b..0000000000000
--- a/clang/test/DebugInfo/CXX/callsite-base.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-// RUN: %clang_cc1 -triple=x86_64-linux -disable-llvm-passes -emit-llvm \
-// RUN:            -debug-info-kind=standalone -dwarf-version=5 -O1 %s \
-// RUN: -o - | FileCheck %s -check-prefix CHECK-BASE
-
-// Simple class with only virtual methods: inlined and not-inlined
-//
-// The following three scenarios are considered:
-// - out-of-line defined virtual member function (f1)
-// - declared-but-not-defined virtual member function (f2)
-// - inline defined virtual member function (f3)
-//
-// 1) We check for a generated 'call_target' for: 'f1', 'f2' and 'f3'.
-// 2) Check that the 'CBase' type is defined.
-
-struct CBase {
-  virtual void f1();
-  virtual void f2();
-  virtual void f3() {}
-};
-void CBase::f1() {}
-
-void bar(CBase *Base) {
-  Base->f1();
-  Base->f2();
-  Base->f3();
-
-  // Because this will instantiate the ctor, the CBase type should be defined.
-  CBase B;
-  B.f1();
-}
-
-// CHECK-BASE: %struct.CBase = type { ptr }
-
-// CHECK-BASE: define {{.*}} @_Z3barP5CBase{{.*}} {
-// CHECK-BASE:   alloca %struct.CBase
-// CHECK-BASE:   call void %1{{.*}} !dbg {{![0-9]+}}, !call_target [[BASE_F1_DCL:![0-9]+]]
-// CHECK-BASE:   call void %3{{.*}} !dbg {{![0-9]+}}, !call_target [[BASE_F2_DCL:![0-9]+]]
-// CHECK-BASE:   call void %5{{.*}} !dbg {{![0-9]+}}, !call_target [[BASE_F3_DCL:![0-9]+]]
-// CHECK-BASE:   call void @_ZN5CBaseC1Ev{{.*}} !dbg {{![0-9]+}}
-// CHECK-BASE:   call void @_ZN5CBase2f1Ev{{.*}} !dbg {{![0-9]+}}
-// CHECK-BASE: }
-
-// CHECK-BASE: [[BASE_F1_DCL]] = {{.*}}!DISubprogram(name: "f1", linkageName: "_ZN5CBase2f1Ev", {{.*}}containingType
-// CHECK-BASE: [[BASE_F2_DCL]] = {{.*}}!DISubprogram(name: "f2", linkageName: "_ZN5CBase2f2Ev", {{.*}}containingType
-// CHECK-BASE: [[BASE_F3_DCL]] = {{.*}}!DISubprogram(name: "f3", linkageName: "_ZN5CBase2f3Ev", {{.*}}containingType
-
-// CHECK-BASE: [[BASE_F1_DEF:![0-9]+]] = {{.*}}!DISubprogram(name: "f1", linkageName: "_ZN5CBase2f1Ev", {{.*}}DISPFlagDefinition
-// CHECK-BASE: [[BASE_F3_DEF:![0-9]+]] = {{.*}}!DISubprogram(name: "f3", linkageName: "_ZN5CBase2f3Ev", {{.*}}DISPFlagDefinition
diff --git a/clang/test/DebugInfo/CXX/callsite-derived.cpp b/clang/test/DebugInfo/CXX/callsite-derived.cpp
deleted file mode 100644
index 3338290bdd829..0000000000000
--- a/clang/test/DebugInfo/CXX/callsite-derived.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-// RUN: %clang_cc1 -triple=x86_64-linux -disable-llvm-passes -emit-llvm \
-// RUN:            -debug-info-kind=constructor -dwarf-version=5 -O1 %s \
-// RUN:            -o - | FileCheck %s -check-prefix CHECK-DERIVED
-
-// Simple base and derived class with virtual and static methods:
-// We check for:
-// - a generated 'call_target' for 'f1'.
-// - not generated 'call_target' for 'f3'.
-
-struct CBase {
-  virtual void f1() {}
-  static void f3();
-};
-
-void CBase::f3() {
-}
-
-void foo(CBase *Base) {
-  CBase::f3();
-}
-
-struct CDerived : public CBase {
-  void f1() {}
-};
-void foo(CDerived *Derived);
-
-int main() {
-  CDerived D;
-  foo(&D);
-
-  return 0;
-}
-
-void foo(CDerived *Derived) {
-  Derived->f1();
-}
-
-// CHECK-DERIVED: define {{.*}} @_Z3fooP5CBase{{.*}} {
-// CHECK-DERIVED: call void @_ZN5CBase2f3Ev{{.*}} !dbg {{![0-9]+}}
-// CHECK-DERIVED: }
-
-// CHECK-DERIVED: define {{.*}} @main{{.*}} {
-// CHECK-DERIVED:  call void @_ZN8CDerivedC1Ev{{.*}} !dbg {{![0-9]+}}
-// CHECK-DERIVED:  call void @_Z3fooP8CDerived{{.*}} !dbg {{![0-9]+}}
-// CHECK-DERIVED: }
-
-// CHECK-DERIVED: define {{.*}} @_ZN8CDerivedC1Ev{{.*}} {
-// CHECK-DERIVED:  call void @_ZN8CDerivedC2Ev{{.*}} !dbg {{![0-9]+}}
-// CHECK-DERIVED: }
-
-// CHECK-DERIVED: define {{.*}} @_Z3fooP8CDerived{{.*}} {
-// CHECK-DERIVED:  call void %1{{.*}} !dbg {{![0-9]+}}, !call_target [[DERIVED_F1_DCL:![0-9]+]]
-// CHECK-DERIVED: }
-
-// CHECK-DERIVED: [[BASE_F1_DCL:![0-9]+]] = {{.*}}!DISubprogram(name: "f1", linkageName: "_ZN5CBase2f1Ev", {{.*}}containingType
-// CHECK-DERIVED: [[DERIVED_F1_DCL]] = {{.*}}!DISubprogram(name: "f1", linkageName: "_ZN8CDerived2f1Ev", {{.*}}containingType
-// CHECK-DERIVED: [[DERIVED_F1_DEF:![0-9]+]] = {{.*}}!DISubprogram(name: "f1", linkageName: "_ZN8CDerived2f1Ev", {{.*}}DISPFlagDefinition
-// CHECK-DERIVED: [[BASE_F1_DEF:![0-9]+]] = {{.*}}!DISubprogram(name: "f1", linkageName: "_ZN5CBase2f1Ev", {{.*}}DISPFlagDefinition
diff --git a/clang/test/DebugInfo/CXX/callsite-edges.cpp b/clang/test/DebugInfo/CXX/callsite-edges.cpp
deleted file mode 100644
index 812cfc1fb4cf2..0000000000000
--- a/clang/test/DebugInfo/CXX/callsite-edges.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-// RUN: %clang_cc1 -triple=x86_64-linux -disable-llvm-passes -emit-llvm \
-// RUN:            -debug-info-kind=constructor -dwarf-version=5 -O1 %s \
-// RUN:            -o - | FileCheck %s -check-prefix CHECK-EDGES
-
-// The following are identified edge cases involving the method being called:
-// 1) Method is declared but not defined in current CU.
-// 2) Pure virtual method but not defined in current CU.
-// 3) Virtual method defined in a deeply nested structure hierarchy.
-
-//---------------------------------------------------------------------
-// 1) Method is declared but not defined in current CU - Pass.
-//    Generate 'call_target' metadata for 'f1' and 'f2'.
-//---------------------------------------------------------------------
-struct CEmpty {
-  virtual void f1();
-  virtual void f2();
-};
-
-void CEmpty::f2() {
-}
-
-void edge_a(CEmpty *Empty) {
-  Empty->f1();
-  Empty->f2();
-}
-
-//---------------------------------------------------------------------
-// 2) Pure virtual method but not defined in current CU - Pass.
-//    Generate 'call_target' metadata for 'f1' and 'f2'.
-//---------------------------------------------------------------------
-struct CBase {
-  virtual void f1() = 0;
-  virtual void f2();
-};
-
-void CBase::f2() {
-}
-
-void edge_b(CBase *Base) {
-  Base->f1();
-  Base->f2();
-}
-
-//---------------------------------------------------------------------
-// 3) Virtual method defined in a deeply nested structure hierarchy - Pass.
-//    Generate 'call_target' metadata for 'd0', 'd1', 'd2' and 'd3'.
-//---------------------------------------------------------------------
-struct CD0 {
-  struct CD1 {
-    virtual void d1();
-  };
-
-  CD1 D1;
-  virtual void d0();
-};
-
-void CD0::d0() {}
-void CD0::CD1::d1() {}
-
-void edge_c(CD0 *D0) {
-  D0->d0();
-
-  CD0::CD1 *D1 = &D0->D1;
-  D1->d1();
-}
-
-// CHECK-EDGES: define {{.*}} @_Z6edge_aP6CEmpty{{.*}} {
-// CHECK-EDGES:  call void %1{{.*}} !dbg {{![0-9]+}}, !call_target [[CEMPTY_F1_DCL:![0-9]+]]
-// CHECK-EDGES:  call void %3{{.*}} !dbg {{![0-9]+}}, !call_target [[CEMPTY_F2_DCL:![0-9]+]]
-// CHECK-EDGES: }
-
-// CHECK-EDGES: define {{.*}} @_Z6edge_bP5CBase{{.*}} {
-// CHECK-EDGES:  call void %1{{.*}} !dbg {{![0-9]+}}, !call_target [[CBASE_F1_DCL:![0-9]+]]
-// CHECK-EDGES:  call void %3{{.*}} !dbg {{![0-9]+}}, !call_target [[CBASE_F2_DCL:![0-9]+]]
-// CHECK-EDGES: }
-
-// CHECK-EDGES: define {{.*}} @_Z6edge_cP3CD0{{.*}} {
-// CHECK-EDGES:  call void %1{{.*}} !dbg {{![0-9]+}}, !call_target [[CD0_D0_DCL:![0-9]+]]
-// CHECK-EDGES:  call void %4{{.*}} !dbg {{![0-9]+}}, !call_target [[CD0_D1_DCL:![0-9]+]]
-// CHECK-EDGES: }
-
-// CHECK-EDGES:  [[CD0_D1_DCL]] = {{.*}}!DISubprogram(name: "d1", linkageName: "_ZN3CD03CD12d1Ev", {{.*}}containingType
-// CHECK-EDGES:  [[CD0_D0_DCL]] = {{.*}}!DISubprogram(name: "d0", linkageName: "_ZN3CD02d0Ev", {{.*}}containingType
-
-// CHECK-EDGES:  [[CBASE_F1_DCL]] = {{.*}}!DISubprogram(name: "f1", linkageName: "_ZN5CBase2f1Ev", {{.*}}containingType
-// CHECK-EDGES:  [[CBASE_F2_DCL]] = {{.*}}!DISubprogram(name: "f2", linkageName: "_ZN5CBase2f2Ev", {{.*}}containingType
-// CHECK-EDGES:  [[CEMPTY_F2_DEF:![0-9]+]] = {{.*}}!DISubprogram(name: "f2", linkageName: "_ZN6CEmpty2f2Ev", {{.*}}DISPFlagDefinition
-// CHECK-EDGES:  [[CEMPTY_F2_DCL]] = {{.*}}!DISubprogram(name: "f2", linkageName: "_ZN6CEmpty2f2Ev", {{.*}}containingType
-// CHECK-EDGES:  [[CEMPTY_F1_DCL]] = {{.*}}!DISubprogram(name: "f1", linkageName: "_ZN6CEmpty2f1Ev", {{.*}}containingType
-// CHECK-EDGES:  [[CBASE_F2_DEF:![0-9]+]] = {{.*}}!DISubprogram(name: "f2", linkageName: "_ZN5CBase2f2Ev", {{.*}}DISPFlagDefinition
-
-// CHECK-EDGES:  [[CD0_D0_DEF:![0-9]+]] = {{.*}}!DISubprogram(name: "d0", linkageName: "_ZN3CD02d0Ev", {{.*}}DISPFlagDefinition
-// CHECK-EDGES:  [[CD0_D1_DEF:![0-9]+]] = {{.*}}!DISubprogram(name: "d1", linkageName: "_ZN3CD03CD12d1Ev", {{.*}}DISPFlagDefinition
diff --git a/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/callsite-dwarf.cpp b/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/callsite-dwarf.cpp
deleted file mode 100644
index 8b4ddf542ddb3..0000000000000
--- a/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/callsite-dwarf.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-// REQUIRES: x86-registered-target
-// RUN: %clang --target=x86_64-linux -c -g -O1 %s -o - | \
-// RUN: llvm-dwarfdump --debug-info - | FileCheck %s --check-prefix=CHECK
-
-// Simple base and derived class with virtual:
-// We check for a generated 'DW_AT_LLVM_virtual_call_origin' for 'foo', that
-// corresponds to the 'call_target' metadata added to the indirect call
-// instruction.
-
-// Note: We should add a test case inside LLDB that make use of the
-//       virtuality call-site target information in DWARF.
-
-struct CBaseOne {
-  virtual void foo(int &);
-};
-
-struct CDerivedOne : CBaseOne {
-  void foo(int &);
-};
-
-void CDerivedOne::foo(int &) {}
-
-struct CBaseTwo {
-  CDerivedOne *DerivedOne;
-};
-
-struct CDerivedTwo : CBaseTwo {
-  void bar(int &);
-};
-
-void CDerivedTwo::bar(int &j) { DerivedOne->foo(j); }
-
-// The IR generated looks like:
-//
-// define dso_local void @_ZN11CDerivedTwo3barERi(...) !dbg !40 {
-// entry:
-//   ..
-//   %vtable = load ptr, ptr %0, align 8
-//   %vfn = getelementptr inbounds ptr, ptr %vtable, i64 0
-//   %2 = load ptr, ptr %vfn, align 8
-//   call void %2(...), !dbg !65, !call_target !25
-//   ret void
-// }
-//
-// !25 = !DISubprogram(name: "foo", linkageName: "_ZN11CDerivedOne3fooERi", ...)
-// !40 = !DISubprogram(name: "bar", linkageName: "_ZN11CDerivedTwo3barERi", ...)
-// !65 = !DILocation(line: 25, column: 15, scope: !40)
-
-// CHECK: DW_TAG_compile_unit
-// CHECK:   DW_TAG_structure_type
-// CHECK:     DW_AT_name	("CDerivedOne")
-// CHECK: [[FOO_DCL:0x[a-f0-9]+]]:    DW_TAG_subprogram
-// CHECK:       DW_AT_name	("foo")
-// CHECK:   DW_TAG_structure_type
-// CHECK:     DW_AT_name	("CBaseOne")
-// CHECK: [[FOO_DEF:0x[a-f0-9]+]]:  DW_TAG_subprogram
-// CHECK:     DW_AT_call_all_calls	(true)
-// CHECK:     DW_AT_specification	([[FOO_DCL]] "{{.*}}foo{{.*}}")
-// CHECK:   DW_TAG_structure_type
-// CHECK:     DW_AT_name	("CDerivedTwo")
-// CHECK:     DW_TAG_subprogram
-// CHECK:       DW_AT_name	("bar")
-// CHECK:   DW_TAG_structure_type
-// CHECK:     DW_AT_name	("CBaseTwo")
-// CHECK:   DW_TAG_subprogram
-// CHECK:     DW_AT_call_all_calls	(true)
-// CHECK:     DW_AT_specification	(0x{{.*}} "{{.*}}bar{{.*}}")
-// CHECK:     DW_TAG_call_site
-// CHECK:       DW_AT_call_target_clobbered	(DW_OP_reg0 RAX)
-// CHECK:       DW_AT_call_tail_call	(true)
-// CHECK:       DW_AT_call_pc	(0x{{.*}})
-// CHECK:       DW_AT_LLVM_virtual_call_origin	([[FOO_DCL]] "{{.*}}foo{{.*}}")
diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.def b/llvm/include/llvm/BinaryFormat/Dwarf.def
index 50b83884c851a..75f1061c471c6 100644
--- a/llvm/include/llvm/BinaryFormat/Dwarf.def
+++ b/llvm/include/llvm/BinaryFormat/Dwarf.def
@@ -647,7 +647,6 @@ HANDLE_DW_AT(0x3e10, LLVM_address_space, 0, LLVM)
 HANDLE_DW_AT(0x3e11, LLVM_lanes, 0, LLVM)
 HANDLE_DW_AT(0x3e12, LLVM_lane_pc, 0, LLVM)
 HANDLE_DW_AT(0x3e13, LLVM_vector_size, 0, LLVM)
-HANDLE_DW_AT(0x3e14, LLVM_virtual_call_origin, 0, LLVM)
 
 // https://llvm.org/docs/AMDGPUUsage.html#address-space-identifier
 HANDLE_DW_ASPACE(0x0, none)
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index 26b6c457a45ba..edb8963ce42b6 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -526,17 +526,11 @@ class LLVM_ABI MachineFunction {
     /// Callee type ids.
     SmallVector<ConstantInt *, 4> CalleeTypeIds;
 
-    /// 'call_target' metadata for the DISubprogram. It is the declaration
-    /// or definition of the target function and might be indirect.
-    MDNode *CallTarget = nullptr;
-
     CallSiteInfo() = default;
 
     /// Extracts the numeric type id from the CallBase's callee_type Metadata,
     /// and sets CalleeTypeIds. This is used as type id for the indirect call in
     /// the call graph section.
-    /// Extracts the MDNode from the CallBase's call_target Metadata to be used
-    /// during the construction of the debug info call site entries.
     LLVM_ABI CallSiteInfo(const CallBase &CB);
   };
 
diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h
index 39699cb19a4b7..37002d3bc227f 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -5936,10 +5936,6 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
                                        LoadSDNode *OriginalLoad,
                                        SelectionDAG &DAG) const;
 
-protected:
-  void setTypeIdForCallsiteInfo(const CallBase *CB, MachineFunction &MF,
-                                MachineFunction::CallSiteInfo &CSInfo) const;
-
 private:
   SDValue foldSetCCWithAnd(EVT VT, SDValue N0, SDValue N1, ISD::CondCode Cond,
                            const SDLoc &DL, DAGCombinerInfo &DCI) const;
diff --git a/llvm/include/llvm/IR/FixedMetadataKinds.def b/llvm/include/llvm/IR/FixedMetadataKinds.def
index 0d79677d7079e..98129985714b2 100644
--- a/llvm/include/llvm/IR/FixedMetadataKinds.def
+++ b/llvm/include/llvm/IR/FixedMetadataKinds.def
@@ -59,4 +59,3 @@ LLVM_FIXED_MD_KIND(MD_captures, "captures", 44)
 LLVM_FIXED_MD_KIND(MD_alloc_token, "alloc_token", 45)
 LLVM_FIXED_MD_KIND(MD_implicit_ref, "implicit.ref", 46)
 LLVM_FIXED_MD_KIND(MD_nofpclass, "nofpclass", 47)
-LLVM_FIXED_MD_KIND(MD_call_target, "call_target", 48)
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index eb55b47dfde2b..e87d3f3ee02a0 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -1349,7 +1349,11 @@ DIE &DwarfCompileUnit::constructCallSiteEntryDIE(
   } else if (CalleeSP) {
     DIE *CalleeDIE = getOrCreateSubprogramDIE(CalleeSP, CalleeF);
     assert(CalleeDIE && "Could not create DIE for call site entry origin");
-    addLinkageNamesToDeclarations(*DD, *CalleeSP, *CalleeDIE);
+    if (AddLinkageNamesToDeclCallOriginsForTuning(DD) &&
+        !CalleeSP->isDefinition() &&
+        !CalleeDIE->findAttribute(dwarf::DW_AT_linkage_name)) {
+      addLinkageName(*CalleeDIE, CalleeSP->getLinkageName());
+    }
 
     addDIEEntry(CallSiteDIE, getDwarf5OrGNUAttr(dwarf::DW_AT_call_origin),
                 *CalleeDIE);
@@ -1887,12 +1891,3 @@ DIE *DwarfCompileUnit::getOrCreateSubprogramDIE(const DISubprogram *SP,
 
   return DwarfUnit::getOrCreateSubprogramDIE(SP, F, Minimal);
 }
-
-void DwarfCompileUnit::addLinkageNamesToDeclarations(
-    const DwarfDebug &DD, const DISubprogram &CalleeSP, DIE &CalleeDIE) {
-  if (AddLinkageNamesToDeclCallOriginsForTuning(&DD) &&
-      !CalleeSP.isDefinition() &&
-      !CalleeDIE.findAttribute(dwarf::DW_AT_linkage_name)) {
-    addLinkageName(CalleeDIE, CalleeSP.getLinkageName());
-  }
-}
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
index ede02c169bffd..04d4556c3ce52 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
@@ -436,10 +436,6 @@ class DwarfCompileUnit final : public DwarfUnit {
   void addBaseTypeRef(DIEValueList &Die, int64_t Idx);
 
   MDNodeSetVector &getDeferredLocalDecls() { return DeferredLocalDecls; }
-
-  void addLinkageNamesToDeclarations(const DwarfDebug &DD,
-                                     const DISubprogram &CalleeSP,
-                                     DIE &CalleeDIE);
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 042c98fa1c02f..f8c2c753b91ce 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -955,30 +955,6 @@ void DwarfDebug::constructCallSiteEntryDIEs(const DISubprogram &SP,
     return true;
   };
 
-  // Create call_target connections for indirect calls.
-  auto addCallSiteTargetForIndirectCalls = [&](const MachineInstr *MI,
-                                               DIE &CallSiteDIE) {
-    const MachineFunction *MF = MI->getMF();
-    const auto &CalleesMap = MF->getCallSitesInfo();
-    auto CSInfo = CalleesMap.find(MI);
-    // Get the information for the call instruction.
-    if (CSInfo == CalleesMap.end() || !CSInfo->second.CallTarget)
-      return;
-
-    MDNode *CallTarget = CSInfo->second.CallTarget;
-    // Add DW_AT_LLVM_virtual_call_origin with the 'call_target' metadata.
-    assert(!CallSiteDIE.findAttribute(dwarf::DW_AT_LLVM_virtual_call_origin) &&
-           "DW_AT_LLVM_virtual_call_origin already exists");
-    const DISubprogram *CalleeSP = dyn_cast<DISubprogram>(CallTarget);
-    DIE *CalleeDIE = CU.getOrCreateSubprogramDIE(CalleeSP, nullptr);
-    assert(CalleeDIE &&...
[truncated]

@github-actions
Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions cpp,h -- clang/lib/CodeGen/CGCall.cpp clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h llvm/include/llvm/CodeGen/MachineFunction.h llvm/include/llvm/CodeGen/TargetLowering.h llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/lib/CodeGen/MIRPrinter.cpp llvm/lib/CodeGen/MachineFunction.cpp llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp llvm/lib/DebugInfo/DWARF/DWARFDie.cpp llvm/lib/Target/AArch64/AArch64ISelLowering.cpp llvm/lib/Target/ARM/ARMISelLowering.cpp llvm/lib/Target/Mips/MipsISelLowering.cpp llvm/lib/Target/RISCV/RISCVISelLowering.cpp llvm/lib/Target/X86/X86ISelLoweringCall.cpp --diff_from_common_commit

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

View the diff from clang-format here.
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index f8c2c753b..9e4bad542 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1460,7 +1460,7 @@ void DwarfDebug::finalizeModuleInfo() {
                             TLOF.getDwarfMacinfoSection()->getBeginSymbol());
       }
     }
-    }
+  }
 
   // Emit all frontend-produced Skeleton CUs, i.e., Clang modules.
   for (auto *CUNode : MMI->getModule()->debug_compile_units())

@ilovepi ilovepi merged commit ec8b9ca into llvm:main Feb 19, 2026
21 of 22 checks passed
@ilovepi ilovepi deleted the fix-debuginfo branch February 19, 2026 20:19
Harrish92 pushed a commit to Harrish92/llvm-project that referenced this pull request Feb 22, 2026
llvm#182343)

…n in DWARF. (llvm#167666)"

This reverts commit 418ba6e.

The commit caused an ICE due to hitting unreachable in
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:1307

Fixes llvm#182337
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.

Unreachable hit in DwarfCompileUnit.cpp

2 participants