[llvm] 4782ac8 - [DebugInfo][RemoveDIs] Use splice in Outliner rather than moveBefore (#79124)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 23 08:23:53 PST 2024


Author: Jeremy Morse
Date: 2024-01-23T16:23:48Z
New Revision: 4782ac8dd3cfa96e14ad4eff1389bbcfda27240f

URL: https://github.com/llvm/llvm-project/commit/4782ac8dd3cfa96e14ad4eff1389bbcfda27240f
DIFF: https://github.com/llvm/llvm-project/commit/4782ac8dd3cfa96e14ad4eff1389bbcfda27240f.diff

LOG: [DebugInfo][RemoveDIs] Use splice in Outliner rather than moveBefore (#79124)

This patch replaces a utility in the outliner that moves the contents of
one basic block into another basic block, with a call to splice instead.
I think it's NFC, however I'd like a second pair of eyes to look at it
just in case.

The reason for doing this is an edge case in the handling of DPValue
objects, the replacement for dbg.values. If there's a variable
assignment "dangling" at the end of a block (which happens when we
delete the terminator), inserting instructions at end() doesn't shift
the DPValue up into the block. We could probably fix this; but it's much
easier to use splice at the only call site that does this.

Patch adds --try-experimental-debuginfo-iterators to a test to exercise
this code path.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/IROutliner.cpp
    llvm/test/Transforms/IROutliner/legal-debug.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/IROutliner.cpp b/llvm/lib/Transforms/IPO/IROutliner.cpp
index a6e19df7c5f1ff..8e6d0e814372d6 100644
--- a/llvm/lib/Transforms/IPO/IROutliner.cpp
+++ b/llvm/lib/Transforms/IPO/IROutliner.cpp
@@ -154,8 +154,7 @@ struct OutlinableGroup {
 /// \param SourceBB - the BasicBlock to pull Instructions from.
 /// \param TargetBB - the BasicBlock to put Instruction into.
 static void moveBBContents(BasicBlock &SourceBB, BasicBlock &TargetBB) {
-  for (Instruction &I : llvm::make_early_inc_range(SourceBB))
-    I.moveBeforePreserving(TargetBB, TargetBB.end());
+  TargetBB.splice(TargetBB.end(), &SourceBB);
 }
 
 /// A function to sort the keys of \p Map, which must be a mapping of constant

diff  --git a/llvm/test/Transforms/IROutliner/legal-debug.ll b/llvm/test/Transforms/IROutliner/legal-debug.ll
index b7b472fa20b3e6..be1182b38fa2d8 100644
--- a/llvm/test/Transforms/IROutliner/legal-debug.ll
+++ b/llvm/test/Transforms/IROutliner/legal-debug.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs
 ; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s | FileCheck %s
+; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s --try-experimental-debuginfo-iterators | FileCheck %s
 
 ; This test checks that debug info is recognized as able to be extracted along
 ; with the other instructions, but is not included in the consolidated function.


        


More information about the llvm-commits mailing list