Apply operation rewrites before updating arguments.
authorRiver Riddle <riverriddle@google.com>
Thu, 23 May 2019 18:11:18 +0000 (11:11 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Sun, 2 Jun 2019 02:58:14 +0000 (19:58 -0700)
--

PiperOrigin-RevId: 249678839

mlir/lib/Transforms/DialectConversion.cpp

index 389b5ad..6ca234a 100644 (file)
@@ -120,14 +120,14 @@ struct DialectConversionRewriter final : public PatternRewriter {
   /// Apply all requested operation rewrites. This method is invoked when the
   /// conversion process succeeds.
   void applyRewrites() {
-    argConverter.applyRewrites();
-
     // Apply all of the rewrites replacements requested during conversion.
     for (auto &repl : replacements) {
       for (unsigned i = 0, e = repl.newValues.size(); i != e; ++i)
         repl.op->getResult(i)->replaceAllUsesWith(repl.newValues[i]);
       repl.op->erase();
     }
+
+    argConverter.applyRewrites();
   }
 
   /// PatternRewriter hook for replacing the results of an operation.