[llvm] [DWARF] Emit line 0 source locations for BB padding nops (PR #99496)

Paul T Robinson via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 22 12:08:14 PDT 2024


================
@@ -3668,3 +3668,19 @@ bool DwarfDebug::alwaysUseRanges(const DwarfCompileUnit &CU) const {
     return true;
   return false;
 }
+
+void DwarfDebug::beginCodeAlignment(const MachineBasicBlock &MBB) {
+  auto *SP = MBB.getParent()->getFunction().getSubprogram();
+
+  bool NoDebug =
+      !SP || SP->getUnit()->getEmissionKind() == DICompileUnit::NoDebug;
+
+  if (NoDebug)
+    return;
+
+  auto PrevLoc = Asm->OutStreamer->getContext().getCurrentDwarfLoc();
+  Asm->OutStreamer->emitDwarfLocDirective(
----------------
pogo59 wrote:

Hmmm yes at the AsmPrinter level we don't know whether we'll need any nops.  That suggests you want to figure this out down in MC when you _do_ know whether you will be emitting any nops. Or, possibly, when encoding the line table, look to see whether there's a line-0 immediately followed by a non-0 at the same offset, and suppress the line-0. Offhand I don't know where those kinds of things happen, other than "somewhere in MC," sorry. 

https://github.com/llvm/llvm-project/pull/99496


More information about the llvm-commits mailing list