Skip to content

Commit 4782ac8

Browse files
authored
[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.
1 parent 6bb7d51 commit 4782ac8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

llvm/lib/Transforms/IPO/IROutliner.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ struct OutlinableGroup {
154154
/// \param SourceBB - the BasicBlock to pull Instructions from.
155155
/// \param TargetBB - the BasicBlock to put Instruction into.
156156
static void moveBBContents(BasicBlock &SourceBB, BasicBlock &TargetBB) {
157-
for (Instruction &I : llvm::make_early_inc_range(SourceBB))
158-
I.moveBeforePreserving(TargetBB, TargetBB.end());
157+
TargetBB.splice(TargetBB.end(), &SourceBB);
159158
}
160159

161160
/// A function to sort the keys of \p Map, which must be a mapping of constant

llvm/test/Transforms/IROutliner/legal-debug.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs
22
; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s | FileCheck %s
3+
; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s --try-experimental-debuginfo-iterators | FileCheck %s
34

45
; This test checks that debug info is recognized as able to be extracted along
56
; with the other instructions, but is not included in the consolidated function.

0 commit comments

Comments
 (0)