[llvm] [NFC][DebugInfo][RemoveDIs] Use iterators to insert in callsite-splitting (PR #74455)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 5 04:01:13 PST 2023


https://github.com/jmorse created https://github.com/llvm/llvm-project/pull/74455

This patch gets call site splitting to use iterators for insertion rather than instruction pointers. When we switch on non-instr debug-info this becomes significant, as the iterators are going to signal whether or not a position is before or after debug-info.

NFC as this isn't going to affect the output of any existing test.

>From fe1007c24248417cd47ac882594a27c4a1e234fa Mon Sep 17 00:00:00 2001
From: Jeremy Morse <jeremy.morse at sony.com>
Date: Mon, 4 Dec 2023 12:48:36 +0000
Subject: [PATCH] [NFC][DebugInfo][RemoveDIs] Use iterators to insert in
 callsite-splitting

This patch gets call site splitting to use iterators for insertion rather than
instruction pointers. When we switch on non-instr debug-info this becomes
significant, as the iterators are going to signal whether or not a position is
before or after debug-info.

NFC as this isn't going to affect the output of any existing test.
---
 llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp b/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
index 47af299dbd473..015a0ab35987c 100644
--- a/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
+++ b/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
@@ -372,10 +372,10 @@ static void splitCallSite(CallBase &CB,
     return;
   }
 
-  auto *OriginalBegin = &*TailBB->begin();
+  BasicBlock::iterator OriginalBegin = TailBB->begin();
   // Replace users of the original call with a PHI mering call-sites split.
   if (CallPN) {
-    CallPN->insertBefore(OriginalBegin);
+    CallPN->insertBefore(*TailBB, OriginalBegin);
     CB.replaceAllUsesWith(CallPN);
   }
 
@@ -399,13 +399,13 @@ static void splitCallSite(CallBase &CB,
       for (auto &Mapping : ValueToValueMaps)
         NewPN->addIncoming(Mapping[CurrentI],
                            cast<Instruction>(Mapping[CurrentI])->getParent());
-      NewPN->insertBefore(&*TailBB->begin());
+      NewPN->insertBefore(*TailBB, TailBB->begin());
       CurrentI->replaceAllUsesWith(NewPN);
     }
     CurrentI->dropDbgValues();
     CurrentI->eraseFromParent();
     // We are done once we handled the first original instruction in TailBB.
-    if (CurrentI == OriginalBegin)
+    if (CurrentI == &*OriginalBegin)
       break;
   }
 }



More information about the llvm-commits mailing list