aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
diff options
context:
space:
mode:
authorDaniel Paoliello <danpao@microsoft.com>2023-05-16 10:58:10 -0700
committerEli Friedman <efriedma@quicinc.com>2023-05-16 10:58:10 -0700
commitf8499d5709e37b4e9a6d2a39c385cfd2c00bad6e (patch)
tree2ba4ae10b61ffc214ea371078a8c67387c2ed3ef /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
parent195621aacb96a4e2f49f5d888e2fc7af20e6e797 (diff)
downloadllvm-f8499d5709e37b4e9a6d2a39c385cfd2c00bad6e.zip
llvm-f8499d5709e37b4e9a6d2a39c385cfd2c00bad6e.tar.gz
llvm-f8499d5709e37b4e9a6d2a39c385cfd2c00bad6e.tar.bz2
Emit the correct flags for the PROC CodeView Debug Symbol
The S_LPROC32_ID and S_GPROC32_ID CodeView Debug Symbols have a flags field which LLVM has had the values for (in the ProcSymFlags enum) but has never actually set. These flags are used by Microsoft-internal tooling that leverages debug information to do binary analysis. Modified LLVM to set the correct flags: - ProcSymFlags::HasOptimizedDebugInfo - always set, as this indicates that debug info is present for optimized builds (if debug info is not emitted for optimized builds, then LLVM won't emit a debug symbol at all). - ProcSymFlags::IsNoReturn and ProcSymFlags::IsNoInline - set if the function has the NoReturn or NoInline attributes respectively. - ProcSymFlags::HasFP - set if the function requires a frame pointer (per TargetFrameLowering::hasFP). Per discussion in review, XFAIL'ing lldb test until someone working on lldb has a chance to look at it. Differential Revision: https://reviews.llvm.org/D148761
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index ce5fe61..8161de5 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -1160,7 +1160,14 @@ void CodeViewDebug::emitDebugInfoForFunction(const Function *GV,
OS.AddComment("Function section index");
OS.emitCOFFSectionIndex(Fn);
OS.AddComment("Flags");
- OS.emitInt8(0);
+ ProcSymFlags ProcFlags = ProcSymFlags::HasOptimizedDebugInfo;
+ if (FI.HasFramePointer)
+ ProcFlags |= ProcSymFlags::HasFP;
+ if (GV->hasFnAttribute(Attribute::NoReturn))
+ ProcFlags |= ProcSymFlags::IsNoReturn;
+ if (GV->hasFnAttribute(Attribute::NoInline))
+ ProcFlags |= ProcSymFlags::IsNoInline;
+ OS.emitInt8(static_cast<uint8_t>(ProcFlags));
// Emit the function display name as a null-terminated string.
OS.AddComment("Function name");
// Truncate the name so we won't overflow the record length field.
@@ -1480,6 +1487,7 @@ void CodeViewDebug::beginFunctionImpl(const MachineFunction *MF) {
CurFn->EncodedLocalFramePtrReg = EncodedFramePtrReg::StackPtr;
CurFn->EncodedParamFramePtrReg = EncodedFramePtrReg::StackPtr;
} else {
+ CurFn->HasFramePointer = true;
// If there is an FP, parameters are always relative to it.
CurFn->EncodedParamFramePtrReg = EncodedFramePtrReg::FramePtr;
if (CurFn->HasStackRealignment) {