[PATCH] D71093: [InstCombine] Insert instructions before adding them to worklist

Jakub Kuderski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 14:54:19 PST 2019


kuhar created this revision.
kuhar added reviewers: fhahn, davide, spatel, foad.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a reviewer: grosser.
Herald added a project: LLVM.

This patch adds instructions to the InstCombine worklist after they are properly inserted. This way we don't get `<badref>`s printed when logging added instructions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71093

Files:
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp


Index: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -3354,10 +3354,6 @@
         // Move the name to the new instruction first.
         Result->takeName(I);
 
-        // Push the new instruction and any users onto the worklist.
-        Worklist.AddUsersToWorkList(*Result);
-        Worklist.Add(Result);
-
         // Insert the new instruction into the basic block...
         BasicBlock *InstParent = I->getParent();
         BasicBlock::iterator InsertPos = I->getIterator();
@@ -3369,6 +3365,10 @@
 
         InstParent->getInstList().insert(InsertPos, Result);
 
+        // Push the new instruction and any users onto the worklist.
+        Worklist.AddUsersToWorkList(*Result);
+        Worklist.Add(Result);
+
         eraseInstFromFunction(*I);
       } else {
         LLVM_DEBUG(dbgs() << "IC: Mod = " << OrigI << '\n'


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71093.232456.patch
Type: text/x-patch
Size: 1039 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191205/cd242742/attachment.bin>


More information about the llvm-commits mailing list