[llvm] [Instruction] Add missing implementation for `moveAfter(InstListType::iterator)` (PR #143093)

Tobias Kamm via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 6 01:51:56 PDT 2025


https://github.com/kammt created https://github.com/llvm/llvm-project/pull/143093

Commit 8e702735090388a3231a863e343f880d0f96fecb introduced a declaration for `Instruction::moveAfter(InstListType::iterator)`. However, its implementation is missing. This PR adds it.

>From 56d8c5f7ce0101c461acfeb9f9938f09c5e0ddff Mon Sep 17 00:00:00 2001
From: Tobias Kamm <tobias.kamm at tum.de>
Date: Fri, 6 Jun 2025 09:29:39 +0200
Subject: [PATCH] [Instruction] Add missing implementation for
 moveAfter(InstListType::iterator)

---
 llvm/lib/IR/Instruction.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index 997f3849d4c1b..202fd4fdd5c5d 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -197,6 +197,13 @@ void Instruction::moveAfter(Instruction *MovePos) {
   moveBeforeImpl(*MovePos->getParent(), NextIt, false);
 }
 
+void Instruction::moveAfter(InstListType::iterator MovePos) {
+  // We want this instruction to be moved to before NextIt in the instruction
+  // list, but before NextIt's debug value range.
+  MovePos.setHeadBit(true);
+  moveBeforeImpl(*MovePos->getParent(), MovePos, false);
+}
+
 void Instruction::moveAfterPreserving(Instruction *MovePos) {
   auto NextIt = std::next(MovePos->getIterator());
   // We want this instruction and its debug range to be moved to before NextIt



More information about the llvm-commits mailing list