[llvm] [DebugInfo][RemoveDIs] Make dropping variable locations explicit (PR #72399)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 20 07:53:34 PST 2023


================
@@ -5179,6 +5184,15 @@ bool SimplifyCFGOpt::simplifyUnreachable(UnreachableInst *UI) {
 
   bool Changed = false;
 
+  // Ensure that any debug-info records that used to occur after the Unreachable
+  // are moved to in front of it -- otherwise they'll "dangle" at the end of
+  // the block.
+  BB->flushTerminatorDbgValues();
+
+  // Debug-info records on the unreachable inst itself should be deleted, as
+  // below we delete everything past the final executable instruction.
+  UI->dropDbgValues();
----------------
jmorse wrote:

They do, and it's arguable that we should keep them, however that's not what the current behaviour with dbg.values is -- the loop immediately below these lines iterates through and deletes any instructions that don't call/branch/signal etc, i.e. anything where it's inevitable that the unreachable will be hit. That includes dbg.values, which get deleted, which is what this addition preserves.

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


More information about the llvm-commits mailing list