Add a couple useful LLVM_DEBUG's to the inliner.
authorSean Silva <silvasean@google.com>
Wed, 18 Dec 2019 20:33:02 +0000 (12:33 -0800)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Wed, 18 Dec 2019 20:33:30 +0000 (12:33 -0800)
This makes it easier to narrow down on ops that are preventing inlining.

PiperOrigin-RevId: 286243868

mlir/lib/Transforms/Inliner.cpp
mlir/lib/Transforms/Utils/InliningUtils.cpp

index 9948a42..b158948 100644 (file)
 #include "mlir/Transforms/InliningUtils.h"
 #include "mlir/Transforms/Passes.h"
 #include "llvm/ADT/SCCIterator.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/Parallel.h"
 
+#define DEBUG_TYPE "inlining"
+
 using namespace mlir;
 
 static llvm::cl::opt<bool> disableCanonicalization(
@@ -173,6 +176,10 @@ static LogicalResult inlineCallsInSCC(Inliner &inliner,
   bool inlinedAnyCalls = false;
   for (unsigned i = 0; i != calls.size(); ++i) {
     ResolvedCall &it = calls[i];
+    LLVM_DEBUG({
+      llvm::dbgs() << "* Considering inlining call: ";
+      it.call.dump();
+    });
     if (!shouldInline(it))
       continue;
 
index e8e6ae0..e8466aa 100644 (file)
@@ -26,6 +26,7 @@
 #include "mlir/IR/Function.h"
 #include "mlir/IR/Operation.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
 #define DEBUG_TYPE "inlining"
@@ -110,8 +111,13 @@ static bool isLegalToInline(InlinerInterface &interface, Region *src,
   for (auto &block : *src) {
     for (auto &op : block) {
       // Check this operation.
-      if (!interface.isLegalToInline(&op, insertRegion, valueMapping))
+      if (!interface.isLegalToInline(&op, insertRegion, valueMapping)) {
+        LLVM_DEBUG({
+          llvm::dbgs() << "* Illegal to inline because of op: ";
+          op.dump();
+        });
         return false;
+      }
       // Check any nested regions.
       if (interface.shouldAnalyzeRecursively(&op) &&
           llvm::any_of(op.getRegions(), [&](Region &region) {