diff options
author | Carlos Alberto Enciso <Carlos.Enciso@sony.com> | 2025-05-28 09:15:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-28 09:15:48 +0100 |
commit | d1b0cbff806b50d399826e79b9a53e4726c21302 (patch) | |
tree | cbc6aab1f113b80f2082cd002c636417a6366dbc /clang/lib/CodeGen/CodeGenModule.h | |
parent | a615975bd9fe413f17ee43b231912ef2e8ccbd64 (diff) | |
download | llvm-d1b0cbff806b50d399826e79b9a53e4726c21302.zip llvm-d1b0cbff806b50d399826e79b9a53e4726c21302.tar.gz llvm-d1b0cbff806b50d399826e79b9a53e4726c21302.tar.bz2 |
[clang][DebugInfo] Add symbol for debugger with VTable information. (#130255)
The IR now includes a global variable for the debugger that holds
the address of the vtable.
Now every class that contains virtual functions, has a static
member (marked as artificial) that identifies where that vtable
is loaded in memory. The unmangled name is '_vtable$'.
This new symbol will allow a debugger to easily associate
classes with the physical location of their VTables using
only the DWARF information. Previously, this had to be done
by searching for ELF symbols with matching names; something
that was time-consuming and error-prone in certain edge cases.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index 1db5c3b..1b67d43 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -1810,6 +1810,15 @@ public: return !getLangOpts().CPlusPlus; } + // Helper to get the alignment for a variable. + unsigned getVtableGlobalVarAlignment(const VarDecl *D = nullptr) { + LangAS AS = GetGlobalVarAddressSpace(D); + unsigned PAlign = getItaniumVTableContext().isRelativeLayout() + ? 32 + : getTarget().getPointerAlign(AS); + return PAlign; + } + private: bool shouldDropDLLAttribute(const Decl *D, const llvm::GlobalValue *GV) const; |