[Mlir-commits] [mlir] 4759351 - [MLIR] Emit debug message if inlining fails

River Riddle llvmlistbot at llvm.org
Wed Jun 10 17:42:27 PDT 2020


Author: Rahul Joshi
Date: 2020-06-10T17:38:41-07:00
New Revision: 475935113c8277fb971f6658aa8df38cd7f80a30

URL: https://github.com/llvm/llvm-project/commit/475935113c8277fb971f6658aa8df38cd7f80a30
DIFF: https://github.com/llvm/llvm-project/commit/475935113c8277fb971f6658aa8df38cd7f80a30.diff

LOG: [MLIR] Emit debug message if inlining fails

Summary: Emit a debug message if inlining fails.

Differential Revision: https://reviews.llvm.org/D81320

Added: 
    

Modified: 
    mlir/include/mlir/IR/OpDefinition.h
    mlir/lib/Transforms/Inliner.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index e92d54ec84f9..da4912d3c1f5 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -260,6 +260,12 @@ class OpFoldResult : public PointerUnion<Attribute, Value> {
   using PointerUnion<Attribute, Value>::PointerUnion;
 };
 
+/// Allow printing to a stream.
+inline raw_ostream &operator<<(raw_ostream &os, OpState &op) {
+  op.print(os, OpPrintingFlags().useLocalScope());
+  return os;
+}
+
 /// This template defines the foldHook as used by AbstractOperation.
 ///
 /// The default implementation uses a general fold method that can be defined on

diff  --git a/mlir/lib/Transforms/Inliner.cpp b/mlir/lib/Transforms/Inliner.cpp
index 04541696ed80..0cd706790bdc 100644
--- a/mlir/lib/Transforms/Inliner.cpp
+++ b/mlir/lib/Transforms/Inliner.cpp
@@ -415,16 +415,15 @@ inlineCallsInSCC(Inliner &inliner, CGUseList &useList,
   for (unsigned i = 0; i != calls.size(); ++i) {
     ResolvedCall it = calls[i];
     bool doInline = shouldInline(it);
+    CallOpInterface call = it.call;
     LLVM_DEBUG({
       if (doInline)
-        llvm::dbgs() << "* Inlining call: ";
+        llvm::dbgs() << "* Inlining call: " << call << "\n";
       else
-        llvm::dbgs() << "* Not inlining call: ";
-      it.call.dump();
+        llvm::dbgs() << "* Not inlining call: " << call << "\n";
     });
     if (!doInline)
       continue;
-    CallOpInterface call = it.call;
     Region *targetRegion = it.targetNode->getCallableRegion();
 
     // If this is the last call to the target node and the node is discardable,
@@ -434,8 +433,10 @@ inlineCallsInSCC(Inliner &inliner, CGUseList &useList,
     LogicalResult inlineResult = inlineCall(
         inliner, call, cast<CallableOpInterface>(targetRegion->getParentOp()),
         targetRegion, /*shouldCloneInlinedRegion=*/!inlineInPlace);
-    if (failed(inlineResult))
+    if (failed(inlineResult)) {
+      LLVM_DEBUG(llvm::dbgs() << "** Failed to inline\n");
       continue;
+    }
     inlinedAnyCalls = true;
 
     // If the inlining was successful, Merge the new uses into the source node.


        


More information about the Mlir-commits mailing list