[Openmp-commits] [PATCH] D116959: [DWARF] Try not to crash for codes with missing debug information
Johannes Doerfert via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Mon Jan 10 10:35:42 PST 2022
jdoerfert created this revision.
jdoerfert added reviewers: ye-luo, jhuber6, dblaikie, tra, arsenm.
Herald added subscribers: bollu, hiraditya.
jdoerfert requested review of this revision.
Herald added subscribers: sstefan1, wdng.
Herald added a project: LLVM.
This prevents crashes in the OpenMP offload pipeline as not everything
is properly annotated with debug information, e.g., the runtimes we link
in. While we might want to have them annotated, it seems to be generally
useful to gracefully handle missing debug info rather than crashing.
TODO: A test is missing and can hopefully be distilled prior to landing.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D116959
Files:
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2126,12 +2126,16 @@
DebugLoc DwarfDebug::emitInitialLocDirective(const MachineFunction &MF,
unsigned CUID) {
+ // If we have code without debug information we need to give up.
+ DISubprogram *MFSP = MF.getFunction().getSubprogram();
+ if (!MFSP)
+ return DebugLoc();
+
// Get beginning of function.
if (DebugLoc PrologEndLoc = findPrologueEndLoc(&MF)) {
// Ensure the compile unit is created if the function is called before
// beginFunction().
- (void)getOrCreateDwarfCompileUnit(
- MF.getFunction().getSubprogram()->getUnit());
+ (void)getOrCreateDwarfCompileUnit(MFSP->getUnit());
// We'd like to list the prologue as "not statements" but GDB behaves
// poorly if we do that. Revisit this with caution/GDB (7.5+) testing.
const DISubprogram *SP = PrologEndLoc->getInlinedAtScope()->getSubprogram();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116959.398694.patch
Type: text/x-patch
Size: 1117 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220110/dd1055f0/attachment-0001.bin>
More information about the Openmp-commits
mailing list