[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 10:54:26 PST 2023


================
@@ -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)
----------------
jmorse wrote:

After being bitten by the buildbots: it turns out in the old version this was a comparison between a freed pointer and another pointer. Turning one of them into an iterator involves dereferencing it, it checking whether it's a sentinel, and subsequently asan firing because of a use-after-free.

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


More information about the llvm-commits mailing list