]> granicus.if.org Git - llvm/commitdiff
[GlobalISel] Only build expensive remarks if they're enabled. NFC.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Mon, 18 Sep 2017 18:50:09 +0000 (18:50 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Mon, 18 Sep 2017 18:50:09 +0000 (18:50 +0000)
r313390 taught 'allowExtraAnalysis' to check whether remarks are
enabled at all.  Use that to only do the expensive instruction printing
if they are.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313552 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/GlobalISel/IRTranslator.cpp
lib/CodeGen/GlobalISel/Utils.cpp

index 1cf1091a8bbb1485c336bd7d3ee758383ce9280a..aaa7b73572f2116dbd1d76ec82f2ef5b55ab832c 100644 (file)
@@ -1291,14 +1291,18 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &CurMF) {
       if (translate(Inst))
         continue;
 
-      std::string InstStrStorage;
-      raw_string_ostream InstStr(InstStrStorage);
-      InstStr << Inst;
-
       OptimizationRemarkMissed R("gisel-irtranslator", "GISelFailure",
                                  Inst.getDebugLoc(), &BB);
-      R << "unable to translate instruction: " << ore::NV("Opcode", &Inst)
-        << ": '" << InstStr.str() << "'";
+      R << "unable to translate instruction: " << ore::NV("Opcode", &Inst);
+
+      if (ORE->allowExtraAnalysis("gisel-irtranslator")) {
+        std::string InstStrStorage;
+        raw_string_ostream InstStr(InstStrStorage);
+        InstStr << Inst;
+
+        R << ": '" << InstStr.str() << "'";
+      }
+
       reportTranslationError(*MF, *TPC, *ORE, R);
       return false;
     }
index 5ecaf5c563f8285845afa7fc09b2ee25ca3efef7..a9f3d73a294b08faef161d11546d59547ed9a5a7 100644 (file)
@@ -99,7 +99,10 @@ void llvm::reportGISelFailure(MachineFunction &MF, const TargetPassConfig &TPC,
                               const MachineInstr &MI) {
   MachineOptimizationRemarkMissed R(PassName, "GISelFailure: ",
                                     MI.getDebugLoc(), MI.getParent());
-  R << Msg << ": " << ore::MNV("Inst", MI);
+  R << Msg;
+  // Printing MI is expensive;  only do it if expensive remarks are enabled.
+  if (MORE.allowExtraAnalysis(PassName))
+    R << ": " << ore::MNV("Inst", MI);
   reportGISelFailure(MF, TPC, MORE, R);
 }