aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorJeremy Morse <jeremy.morse@sony.com>2023-12-05 14:05:00 +0000
committerGitHub <noreply@github.com>2023-12-05 14:05:00 +0000
commit186695929db632b057334757923d1cab1aa395ca (patch)
treedcab1ced5d9c5ce7edccfe48cd29c9ad50c7d721 /llvm/lib/IR
parentcd865e36dbc0b1778739348ac9a25eb18b5c5c16 (diff)
downloadllvm-186695929db632b057334757923d1cab1aa395ca.zip
llvm-186695929db632b057334757923d1cab1aa395ca.tar.gz
llvm-186695929db632b057334757923d1cab1aa395ca.tar.bz2
[DebugInfo][RemoveDIs] Cope with instructions moving after themselves (#74113)
We occasionally move instructions to their own positions, which is not an error, and has no effect on the program. However, if dbg.value intrinsics are present then they can effectively be moved without any other effect on the program. This is a problem if we're using non-instruction debug-info: a moveAfter that appears to be a no-op in RemoveDIs mode can jump in front of intrinsics in dbg.value mode. Thus: if an instruction is moved to itself and the head bit is set, force attached debug-info to shift down one instruction, which replicates the dbg.value behaviour.
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/Instruction.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index a6e43de..920a2ec 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -200,8 +200,9 @@ void Instruction::moveBeforeImpl(BasicBlock &BB, InstListType::iterator I,
// If we've been given the "Preserve" flag, then just move the DPValues with
// the instruction, no more special handling needed.
if (BB.IsNewDbgInfoFormat && DbgMarker && !Preserve) {
- if (I != this->getIterator()) {
- // "this" is definitely moving; detach any existing DPValues.
+ if (I != this->getIterator() || InsertAtHead) {
+ // "this" is definitely moving in the list, or it's moving ahead of its
+ // attached DPValues. Detach any existing DPValues.
handleMarkerRemoval();
}
}