[NFC] Check if P is a pass manager on entry to emitInstrCountChangedRemark

There's no point in finding a function to use for remark output when we're
not going to emit anything.

llvm-svn: 341252
GitOrigin-RevId: 397c05dd7d8f4a99659d5f4e6fdd07f29a3bfd5e
diff --git a/lib/IR/LegacyPassManager.cpp b/lib/IR/LegacyPassManager.cpp
index 3c97d33..cfec2c9 100644
--- a/lib/IR/LegacyPassManager.cpp
+++ b/lib/IR/LegacyPassManager.cpp
@@ -144,6 +144,13 @@
 void PMDataManager::emitInstrCountChangedRemark(Pass *P, Module &M,
                                                 int64_t Delta,
                                                 unsigned CountBefore) {
+  // If it's a pass manager, don't emit a remark. (This hinges on the assumption
+  // that the only passes that return non-null with getAsPMDataManager are pass
+  // managers.) The reason we have to do this is to avoid emitting remarks for
+  // CGSCC passes.
+  if (P->getAsPMDataManager())
+    return;
+
   // We need a function containing at least one basic block in order to output
   // remarks. Since it's possible that the first function in the module doesn't
   // actually contain a basic block, we have to go and find one that's suitable
@@ -157,13 +164,6 @@
 
   // We found a function containing at least one basic block.
   Function *F = &*It;
-
-  // If it's a pass manager, don't emit a remark. (This hinges on the assumption
-  // that the only passes that return non-null with getAsPMDataManager are pass
-  // managers.) The reason we have to do this is to avoid emitting remarks for
-  // CGSCC passes.
-  if (P->getAsPMDataManager())
-    return;
   int64_t CountAfter = static_cast<int64_t>(CountBefore) + Delta;
   BasicBlock &BB = *F->begin();
   OptimizationRemarkAnalysis R("size-info", "IRSizeChange",