Skip to content

Call site entries for declared C++ member functions not reported in debug info #161962

@jryans

Description

@jryans

When the following...

class A {
public:
  virtual void setVal(bool v);
  bool validation;
};

class B {
public:
  virtual void setVal(bool v);
  A a;
};

class B1 : public B {
public:
  void setVal(bool v) override { a.setVal(v); }
};

int main(int argc, char **argv) {
  B1 b;
  b.setVal(argc);
}

...is compiled with Clang 21.1.0 at -O2, the call from B1.setVal to A.setVal becomes a tail call:

define linkonce_odr dso_local void @B1::setVal(bool)(ptr noundef nonnull align 8 dereferenceable(24) %this, i1 noundef zeroext %v) unnamed_addr #2 comdat align 2 !dbg !85 {
entry:
    #dbg_value(ptr %this, !84, !DIExpression(), !92)
    #dbg_value(i1 %v, !87, !DIExpression(DW_OP_LLVM_convert, 1, DW_ATE_unsigned, DW_OP_LLVM_convert, 8, DW_ATE_unsigned, DW_OP_stack_value), !92)
  %a = getelementptr inbounds nuw i8, ptr %this, i64 8, !dbg !93
  tail call void @A::setVal(bool)(ptr noundef nonnull align 8 dereferenceable(9) %a, i1 noundef zeroext %v), !dbg !94
  ret void, !dbg !95
}
B1::setVal(bool):
 add    rdi,0x8
 jmp    9 <B1::setVal(bool)+0x9>
    R_X86_64_PLT32 A::setVal(bool)-0x4

...but there is no DW_TAG_call_site DIE marking this as a tail call in debug info. If we check GCC 15.2 at -O2, it has the expected behaviour of using a tail call and also reporting the tail call via DW_TAG_call_site in DWARF.

Example available on Compiler Explorer.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions