From: Rahul Joshi Date: Thu, 11 Jun 2020 00:37:59 +0000 (-0700) Subject: [MLIR] Emit debug message if inlining fails X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=475935113c8277fb971f6658aa8df38cd7f80a30;p=platform%2Fupstream%2Fllvm.git [MLIR] Emit debug message if inlining fails Summary: Emit a debug message if inlining fails. Differential Revision: https://reviews.llvm.org/D81320 --- diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h index e92d54e..da4912d 100644 --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -260,6 +260,12 @@ class OpFoldResult : public PointerUnion { using PointerUnion::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 04541696..0cd7067 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(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.