[llvm] [CodeGen] Fix InstructionCount remarks for MI bundles (PR #107621)

Francis Visoiu Mistrih via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 1 18:04:52 PDT 2024


================
@@ -1845,12 +1844,23 @@ void AsmPrinter::emitFunctionBody() {
         break;
       default:
         emitInstruction(&MI);
-        if (CanDoExtraAnalysis) {
-          MCInst MCI;
-          MCI.setOpcode(MI.getOpcode());
-          auto Name = OutStreamer->getMnemonic(MCI);
-          auto I = MnemonicCounts.insert({Name, 0u});
-          I.first->second++;
+        auto CountInstruction = [&](unsigned Opcode) {
+          ++NumInstsInFunction;
+          if (CanDoExtraAnalysis) {
+            MCInst MCI;
+            MCI.setOpcode(Opcode);
+            auto Name = OutStreamer->getMnemonic(MCI);
+            ++MnemonicCounts[Name];
+          }
+        };
+        if (!MI.isBundle()) {
+          CountInstruction(MI.getOpcode());
+          break;
+        }
+        // Separately count all the instructions in a bundle.
----------------
francisvm wrote:

yeah, maybe the code setting `HasAnyRealCode` should also check for `isMetaInstruction`

https://github.com/llvm/llvm-project/pull/107621


More information about the llvm-commits mailing list