[llvm] Changed stat passes to count instructions before and after optimizations (PR #188837)

IƱaki V Arrechea via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 27 12:59:18 PDT 2026


https://github.com/InakiVA updated https://github.com/llvm/llvm-project/pull/188837

>From 290534ec8089d47081587e51c131825ff91c93b1 Mon Sep 17 00:00:00 2001
From: Inaki Arrechea <inakiarrechea at google.com>
Date: Thu, 26 Mar 2026 20:45:30 +0000
Subject: [PATCH 1/3] Changed stat passes to count instructions before and
 after optimizations

---
 .../Analysis/FunctionPropertiesAnalysis.h     |  3 +
 llvm/include/llvm/Analysis/InstCount.h        |  5 +-
 .../Analysis/FunctionPropertiesAnalysis.cpp   | 29 ++++++--
 llvm/lib/Analysis/InstCount.cpp               | 74 +++++++++++++++----
 llvm/lib/Passes/PassBuilderPipelines.cpp      | 49 +++++++++---
 .../func-properties-analysis-diff.ll          | 25 +++++++
 ...s-stats.ll => func-properties-analysis.ll} | 20 ++---
 .../test/Analysis/InstCount/instcount-diff.ll | 25 +++++++
 llvm/test/Analysis/InstCount/instcount.ll     | 24 +++---
 9 files changed, 200 insertions(+), 54 deletions(-)
 create mode 100644 llvm/test/Analysis/FunctionPropertiesAnalysis/func-properties-analysis-diff.ll
 rename llvm/test/Analysis/FunctionPropertiesAnalysis/{properties-stats.ll => func-properties-analysis.ll} (81%)
 create mode 100644 llvm/test/Analysis/InstCount/instcount-diff.ll

diff --git a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
index 1619671d8f7dc..50b58b7133d36 100644
--- a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
+++ b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
@@ -187,7 +187,10 @@ class FunctionPropertiesPrinterPass
 /// Statistics pass for the FunctionPropertiesAnalysis results.
 struct FunctionPropertiesStatisticsPass
     : PassInfoMixin<FunctionPropertiesStatisticsPass> {
+  explicit FunctionPropertiesStatisticsPass(bool IsBeforeOptimization = false)
+      : IsBeforeOptimization(IsBeforeOptimization) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
+  bool IsBeforeOptimization;
 };
 
 /// Correctly update FunctionPropertiesInfo post-inlining. A
diff --git a/llvm/include/llvm/Analysis/InstCount.h b/llvm/include/llvm/Analysis/InstCount.h
index e5ce822caf6ef..fe03ceb680f4c 100644
--- a/llvm/include/llvm/Analysis/InstCount.h
+++ b/llvm/include/llvm/Analysis/InstCount.h
@@ -20,7 +20,10 @@ namespace llvm {
 class Function;
 
 struct InstCountPass : PassInfoMixin<InstCountPass> {
-  PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
+  explicit InstCountPass(bool IsBeforeOptimization = false)
+      : IsBeforeOptimization(IsBeforeOptimization) {}
+  PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
+  bool IsBeforeOptimization;
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
index 4a66d8835281a..bf63f2b559f52 100644
--- a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
+++ b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
@@ -29,9 +29,16 @@ using namespace llvm;
 
 #define DEBUG_TYPE "func-properties-stats"
 
-#define FUNCTION_PROPERTY(Name, Description) STATISTIC(Num##Name, Description);
+#define FUNCTION_PROPERTY(Name, Description)                                   \
+  STATISTIC(Num##Name##BeforeOptimization,                                     \
+            Description " (before optimizations)");                            \
+  STATISTIC(Num##Name##AfterOptimization, Description " (after "               \
+                                                      "optimizations)");
 #define DETAILED_FUNCTION_PROPERTY(Name, Description)                          \
-  STATISTIC(Num##Name, Description);
+  STATISTIC(Num##Name##BeforeOptimization,                                     \
+            Description " (before optimizations)");                            \
+  STATISTIC(Num##Name##AfterOptimization, Description " (after "               \
+                                                      "optimizations)");
 #include "llvm/IR/FunctionProperties.def"
 
 namespace llvm {
@@ -378,11 +385,23 @@ FunctionPropertiesStatisticsPass::run(Function &F,
   LLVM_DEBUG(dbgs() << "STATSCOUNT: running on function " << F.getName()
                     << "\n");
   auto &AnalysisResults = FAM.getResult<FunctionPropertiesAnalysis>(F);
-
-#define FUNCTION_PROPERTY(Name, Description) Num##Name += AnalysisResults.Name;
+  if (IsBeforeOptimization) {
+#define FUNCTION_PROPERTY(Name, Description)                                   \
+  Num##Name##BeforeOptimization += AnalysisResults.Name;
+#define DETAILED_FUNCTION_PROPERTY(Name, Description)                          \
+  Num##Name##BeforeOptimization += AnalysisResults.Name;
+#include "llvm/IR/FunctionProperties.def"
+#undef FUNCTION_PROPERTY
+#undef DETAILED_FUNCTION_PROPERTY
+  } else {
+#define FUNCTION_PROPERTY(Name, Description)                                   \
+  Num##Name##AfterOptimization += AnalysisResults.Name;
 #define DETAILED_FUNCTION_PROPERTY(Name, Description)                          \
-  Num##Name += AnalysisResults.Name;
+  Num##Name##AfterOptimization += AnalysisResults.Name;
 #include "llvm/IR/FunctionProperties.def"
+#undef FUNCTION_PROPERTY
+#undef DETAILED_FUNCTION_PROPERTY
+  }
 
   return PreservedAnalyses::all();
 }
diff --git a/llvm/lib/Analysis/InstCount.cpp b/llvm/lib/Analysis/InstCount.cpp
index 7a797767f97cb..e65da22a57c39 100644
--- a/llvm/lib/Analysis/InstCount.cpp
+++ b/llvm/lib/Analysis/InstCount.cpp
@@ -21,34 +21,76 @@ using namespace llvm;
 
 #define DEBUG_TYPE "instcount"
 
-STATISTIC(TotalInsts, "Number of instructions (of all types)");
-STATISTIC(TotalBlocks, "Number of basic blocks");
-STATISTIC(TotalFuncs, "Number of non-external functions");
-STATISTIC(LargestFunctionSize,
-          "Largest number of instructions in a single function");
-STATISTIC(LargestFunctionBBCount,
-          "Largest number of basic blocks in a single function");
+STATISTIC(TotalInstsBeforeOptimization,
+          "Number of instructions of all types (before optimizations)");
+STATISTIC(TotalInstsAfterOptimization,
+          "Number of instructions of all types (after optimizations)");
+STATISTIC(TotalBlocksBeforeOptimization,
+          "Number of basic blocks (before optimizations)");
+STATISTIC(TotalBlocksAfterOptimization,
+          "Number of basic blocks (after optimizations)");
+STATISTIC(TotalFuncsBeforeOptimization,
+          "Number of non-external functions (before optimizations)");
+STATISTIC(TotalFuncsAfterOptimization,
+          "Number of non-external functions (after optimizations)");
+STATISTIC(LargestFunctionSizeBeforeOptimization,
+          "Largest number of instructions in a single function (before "
+          "optimizations)");
+STATISTIC(LargestFunctionSizeAfterOptimization,
+          "Largest number of instructions in a single function (after "
+          "optimizations)");
+STATISTIC(LargestFunctionBBCountBeforeOptimization,
+          "Largest number of basic blocks in a single function (before "
+          "optimizations)");
+STATISTIC(LargestFunctionBBCountAfterOptimization,
+          "Largest number of basic blocks in a single function (after "
+          "optimizations)");
 
 #define HANDLE_INST(N, OPCODE, CLASS)                                          \
-  STATISTIC(Num##OPCODE##Inst, "Number of " #OPCODE " insts");
+  STATISTIC(Num##OPCODE##InstBeforeOptimization,                               \
+            "Number of " #OPCODE " insts (before optimizations)");             \
+  STATISTIC(Num##OPCODE##InstAfterOptimization,                                \
+            "Number of " #OPCODE " insts (after optimizations)");
 
 #include "llvm/IR/Instruction.def"
 
 namespace {
 class InstCount : public InstVisitor<InstCount> {
   friend class InstVisitor<InstCount>;
+  bool IsBeforeOptimization;
+
+public:
+  InstCount(bool IsBeforeOptimization)
+      : IsBeforeOptimization(IsBeforeOptimization) {}
 
   void visitFunction(Function &F) {
-    ++TotalFuncs;
-    LargestFunctionSize.updateMax(F.getInstructionCount());
-    LargestFunctionBBCount.updateMax(F.size());
+    if (IsBeforeOptimization) {
+      ++TotalFuncsBeforeOptimization;
+      LargestFunctionSizeBeforeOptimization.updateMax(F.getInstructionCount());
+      LargestFunctionBBCountBeforeOptimization.updateMax(F.size());
+    } else {
+      ++TotalFuncsAfterOptimization;
+      LargestFunctionSizeAfterOptimization.updateMax(F.getInstructionCount());
+      LargestFunctionBBCountAfterOptimization.updateMax(F.size());
+    }
+  }
+
+  void visitBasicBlock(BasicBlock &BB) {
+    if (IsBeforeOptimization)
+      ++TotalBlocksBeforeOptimization;
+    else
+      ++TotalBlocksAfterOptimization;
   }
-  void visitBasicBlock(BasicBlock &BB) { ++TotalBlocks; }
 
 #define HANDLE_INST(N, OPCODE, CLASS)                                          \
   void visit##OPCODE(CLASS &) {                                                \
-    ++Num##OPCODE##Inst;                                                       \
-    ++TotalInsts;                                                              \
+    if (IsBeforeOptimization) {                                                \
+      ++Num##OPCODE##InstBeforeOptimization;                                   \
+      ++TotalInstsBeforeOptimization;                                          \
+    } else {                                                                   \
+      ++Num##OPCODE##InstAfterOptimization;                                    \
+      ++TotalInstsAfterOptimization;                                           \
+    }                                                                          \
   }
 
 #include "llvm/IR/Instruction.def"
@@ -64,7 +106,7 @@ PreservedAnalyses InstCountPass::run(Function &F,
                                      FunctionAnalysisManager &FAM) {
   LLVM_DEBUG(dbgs() << "INSTCOUNT: running on function " << F.getName()
                     << "\n");
-  InstCount().visit(F);
+  InstCount(this->IsBeforeOptimization).visit(F);
 
   return PreservedAnalyses::all();
-}
+}
\ No newline at end of file
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 5e4688f4dd7ef..f42bf1326a6b2 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -417,13 +417,24 @@ void PassBuilder::invokePipelineEarlySimplificationEPCallbacks(
 }
 
 // Helper to add AnnotationRemarksPass.
-static void addAnnotationRemarksPass(ModulePassManager &MPM) {
-  MPM.addPass(createModuleToFunctionPassAdaptor(AnnotationRemarksPass()));
+static void addAnnotationRemarksPass(ModulePassManager &MPM,
+                                     bool IsBeforeOptimization = false) {
   // Count the stats for InstCount and FunctionPropertiesAnalysis
+  if (IsBeforeOptimization && AreStatisticsEnabled()) {
+    MPM.addPass(
+        createModuleToFunctionPassAdaptor(InstCountPass(IsBeforeOptimization)));
+    MPM.addPass(createModuleToFunctionPassAdaptor(
+        FunctionPropertiesStatisticsPass(IsBeforeOptimization)));
+    return;
+  }
+
+  MPM.addPass(createModuleToFunctionPassAdaptor(AnnotationRemarksPass()));
+
   if (AreStatisticsEnabled()) {
-    MPM.addPass(createModuleToFunctionPassAdaptor(InstCountPass()));
     MPM.addPass(
-        createModuleToFunctionPassAdaptor(FunctionPropertiesStatisticsPass()));
+        createModuleToFunctionPassAdaptor(InstCountPass(IsBeforeOptimization)));
+    MPM.addPass(createModuleToFunctionPassAdaptor(
+        FunctionPropertiesStatisticsPass(IsBeforeOptimization)));
   }
 }
 
@@ -1719,6 +1730,9 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
     return buildO0DefaultPipeline(Level, Phase);
 
   ModulePassManager MPM;
+  // Emit annotation remarks. Must go at the end of the pipeline to see the
+  // final state of the IR.
+  addAnnotationRemarksPass(MPM, true);
 
   // Currently this pipeline is only invoked in an LTO pre link pass or when we
   // are not running LTO. If that changes the below checks may need updating.
@@ -1752,11 +1766,12 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
       PGOOpt->Action == PGOOptions::SampleUse)
     MPM.addPass(PseudoProbeUpdatePass());
 
+  if (isLTOPreLink(Phase))
+    addRequiredLTOPreLinkPasses(MPM);
+
   // Emit annotation remarks.
   addAnnotationRemarksPass(MPM);
 
-  if (isLTOPreLink(Phase))
-    addRequiredLTOPreLinkPasses(MPM);
   return MPM;
 }
 
@@ -1764,6 +1779,9 @@ ModulePassManager
 PassBuilder::buildFatLTODefaultPipeline(OptimizationLevel Level, bool ThinLTO,
                                         bool EmitSummary) {
   ModulePassManager MPM;
+
+  addAnnotationRemarksPass(MPM, true);
+
   if (ThinLTO)
     MPM.addPass(buildThinLTOPreLinkDefaultPipeline(Level));
   else
@@ -1803,9 +1821,10 @@ PassBuilder::buildFatLTODefaultPipeline(OptimizationLevel Level, bool ThinLTO,
     // otherwise, just use module optimization
     MPM.addPass(
         buildModuleOptimizationPipeline(Level, ThinOrFullLTOPhase::None));
-    // Emit annotation remarks.
-    addAnnotationRemarksPass(MPM);
   }
+  // Emit annotation remarks.
+  addAnnotationRemarksPass(MPM);
+
   return MPM;
 }
 
@@ -1816,6 +1835,8 @@ PassBuilder::buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level) {
 
   ModulePassManager MPM;
 
+  addAnnotationRemarksPass(MPM, true);
+
   // Convert @llvm.global.annotations to !annotation metadata.
   MPM.addPass(Annotation2MetadataPass());
 
@@ -1863,11 +1884,11 @@ PassBuilder::buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level) {
   invokeOptimizerLastEPCallbacks(MPM, Level,
                                  /*Phase=*/ThinOrFullLTOPhase::ThinLTOPreLink);
 
+  addRequiredLTOPreLinkPasses(MPM);
+
   // Emit annotation remarks.
   addAnnotationRemarksPass(MPM);
 
-  addRequiredLTOPreLinkPasses(MPM);
-
   return MPM;
 }
 
@@ -1875,6 +1896,8 @@ ModulePassManager PassBuilder::buildThinLTODefaultPipeline(
     OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary) {
   ModulePassManager MPM;
 
+  addAnnotationRemarksPass(MPM, true);
+
   // If we are invoking this without a summary index noting that we are linking
   // with a library containing the necessary APIs, remove any MemProf related
   // attributes and metadata.
@@ -1923,6 +1946,8 @@ ModulePassManager PassBuilder::buildThinLTODefaultPipeline(
     // globals in the object file.
     MPM.addPass(EliminateAvailableExternallyPass());
     MPM.addPass(GlobalDCEPass());
+
+    addAnnotationRemarksPass(MPM, false);
     return MPM;
   }
   if (!UseCtxProfile.empty()) {
@@ -1955,6 +1980,8 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
                                      ModuleSummaryIndex *ExportSummary) {
   ModulePassManager MPM;
 
+  addAnnotationRemarksPass(MPM, true);
+
   invokeFullLinkTimeOptimizationEarlyEPCallbacks(MPM, Level);
 
   // If we are invoking this without a summary index noting that we are linking
@@ -2328,6 +2355,8 @@ PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
 
   ModulePassManager MPM;
 
+  addAnnotationRemarksPass(MPM, true);
+
   // Perform pseudo probe instrumentation in O0 mode. This is for the
   // consistency between different build modes. For example, a LTO build can be
   // mixed with an O0 prelink and an O2 postlink. Loading a sample profile in
diff --git a/llvm/test/Analysis/FunctionPropertiesAnalysis/func-properties-analysis-diff.ll b/llvm/test/Analysis/FunctionPropertiesAnalysis/func-properties-analysis-diff.ll
new file mode 100644
index 0000000000000..40dc0271faa77
--- /dev/null
+++ b/llvm/test/Analysis/FunctionPropertiesAnalysis/func-properties-analysis-diff.ll
@@ -0,0 +1,25 @@
+; REQUIRES: asserts
+; RUN: opt -stats -enable-detailed-function-properties -O3 -disable-output < %s 2>&1 | FileCheck %s
+
+; CHECK-DAG: 4 func-properties-stats - Number of basic blocks (before optimizations)
+; CHECK-DAG: 5 func-properties-stats - Number of instructions (of all types) (before optimizations)
+; CHECK-DAG: 4 func-properties-stats - Number of basic block successors (before optimizations)
+; CHECK-DAG: 1 func-properties-stats - Number of basic blocks (after optimizations)
+; CHECK-DAG: 1 func-properties-stats - Number of instructions (of all types) (after optimizations)
+; CHECK-NOT: func-properties-stats - Number of basic block successors (after optimizations)
+
+define i32 @test_cfg() {
+entry:
+  ; This branch is trivially resolvable
+  br i1 true, label %then, label %else
+
+then:
+  br label %end
+
+else:
+  br label %end
+
+end:
+  %phi = phi i32 [ 1, %then ], [ 2, %else ]
+  ret i32 %phi
+}
\ No newline at end of file
diff --git a/llvm/test/Analysis/FunctionPropertiesAnalysis/properties-stats.ll b/llvm/test/Analysis/FunctionPropertiesAnalysis/func-properties-analysis.ll
similarity index 81%
rename from llvm/test/Analysis/FunctionPropertiesAnalysis/properties-stats.ll
rename to llvm/test/Analysis/FunctionPropertiesAnalysis/func-properties-analysis.ll
index f7907c73728a5..45370b47e833d 100644
--- a/llvm/test/Analysis/FunctionPropertiesAnalysis/properties-stats.ll
+++ b/llvm/test/Analysis/FunctionPropertiesAnalysis/func-properties-analysis.ll
@@ -7,15 +7,15 @@
 ; RUN: opt -stats -enable-detailed-function-properties -disable-output -O3 < %s 2>&1 | FileCheck %s
 ; RUN: opt -stats -enable-detailed-function-properties -disable-output -O0 < %s 2>&1 | FileCheck %s
 
-; CHECK-DAG: 10 func-properties-stats - Number of basic blocks
-; CHECK-DAG: 8 func-properties-stats - Number of branch instructions
-; CHECK-DAG: 10 func-properties-stats - Number of branch successors
-; CHECK-DAG: 2 func-properties-stats - Number of conditional branch instructions
-; CHECK-DAG: 6 func-properties-stats - Number of unconditional branch instructions
-; CHECK-DAG: 18 func-properties-stats - Number of instructions (of all types)
-; CHECK-DAG: 14 func-properties-stats - Number of basic block successors
-; CHECK-DAG: 1 func-properties-stats - Number of switch instructions
-; CHECK-DAG: 4 func-properties-stats - Number of switch successors
+; CHECK-DAG: 10 func-properties-stats - Number of basic blocks ({{before|after}} optimizations)
+; CHECK-DAG: 8 func-properties-stats - Number of branch instructions ({{before|after}} optimizations)
+; CHECK-DAG: 10 func-properties-stats - Number of branch successors ({{before|after}} optimizations)
+; CHECK-DAG: 2 func-properties-stats - Number of conditional branch instructions ({{before|after}} optimizations)
+; CHECK-DAG: 6 func-properties-stats - Number of unconditional branch instructions ({{before|after}} optimizations)
+; CHECK-DAG: 18 func-properties-stats - Number of instructions (of all types) ({{before|after}} optimizations)
+; CHECK-DAG: 14 func-properties-stats - Number of basic block successors ({{before|after}} optimizations)
+; CHECK-DAG: 1 func-properties-stats - Number of switch instructions ({{before|after}} optimizations)
+; CHECK-DAG: 4 func-properties-stats - Number of switch successors ({{before|after}} optimizations)
 
 
 define void @foo(i32 %i, i32 %j, i32 %n) {
@@ -67,4 +67,4 @@ declare void @g()
 declare void @h()
 declare void @k()
 declare void @l()
-declare void @m()
+declare void @m()
\ No newline at end of file
diff --git a/llvm/test/Analysis/InstCount/instcount-diff.ll b/llvm/test/Analysis/InstCount/instcount-diff.ll
new file mode 100644
index 0000000000000..5096e21f2b668
--- /dev/null
+++ b/llvm/test/Analysis/InstCount/instcount-diff.ll
@@ -0,0 +1,25 @@
+; REQUIRES: asserts
+; RUN: opt -stats -O3 -disable-output < %s 2>&1 | FileCheck %s
+
+; CHECK-DAG: 4 instcount - Number of basic blocks (before optimizations)
+; CHECK-DAG: 1 instcount - Number of basic blocks (after optimizations)
+; CHECK-DAG: 5 instcount - Number of instructions of all types (before optimizations)
+; CHECK-DAG: 1 instcount - Number of instructions of all types (after optimizations)
+; CHECK-DAG: 1 instcount - Number of CondBr insts (before optimizations)
+; CHECK-NOT: instcount - Number of CondBr insts (after optimizations)
+
+define i32 @test_cfg() {
+entry:
+  ; This branch is trivially resolvable
+  br i1 true, label %then, label %else
+
+then:
+  br label %end
+
+else:
+  br label %end
+
+end:
+  %phi = phi i32 [ 1, %then ], [ 2, %else ]
+  ret i32 %phi
+}
\ No newline at end of file
diff --git a/llvm/test/Analysis/InstCount/instcount.ll b/llvm/test/Analysis/InstCount/instcount.ll
index 9c4d3f3d06457..df53527798efc 100644
--- a/llvm/test/Analysis/InstCount/instcount.ll
+++ b/llvm/test/Analysis/InstCount/instcount.ll
@@ -7,17 +7,17 @@
 ; RUN: opt -stats -O3 -disable-output < %s 2>&1 | FileCheck %s
 ; RUN: opt -stats -O0 -disable-output < %s 2>&1 | FileCheck %s
 
-; CHECK-DAG: 10 instcount - Largest number of basic blocks in a single function
-; CHECK-DAG: 18 instcount - Largest number of instructions in a single function
-; CHECK-DAG: 6 instcount - Number of UncondBr insts
-; CHECK-DAG: 2 instcount - Number of CondBr insts
-; CHECK-DAG: 6 instcount - Number of Call insts
-; CHECK-DAG: 2 instcount - Number of ICmp insts
-; CHECK-DAG: 2 instcount - Number of Ret insts
-; CHECK-DAG: 1 instcount - Number of Switch insts
-; CHECK-DAG: 11 instcount - Number of basic blocks
-; CHECK-DAG: 2 instcount - Number of non-external functions
-; CHECK-DAG: 19 instcount - Number of instructions (of all types)
+; CHECK-DAG: 10 instcount - Largest number of basic blocks in a single function ({{before|after}} optimizations)
+; CHECK-DAG: 18 instcount - Largest number of instructions in a single function ({{before|after}} optimizations)
+; CHECK-DAG: 6 instcount - Number of UncondBr insts ({{before|after}} optimizations)
+; CHECK-DAG: 2 instcount - Number of CondBr insts ({{before|after}} optimizations)
+; CHECK-DAG: 6 instcount - Number of Call insts ({{before|after}} optimizations)
+; CHECK-DAG: 2 instcount - Number of ICmp insts ({{before|after}} optimizations)
+; CHECK-DAG: 2 instcount - Number of Ret insts ({{before|after}} optimizations)
+; CHECK-DAG: 1 instcount - Number of Switch insts ({{before|after}} optimizations)
+; CHECK-DAG: 11 instcount - Number of basic blocks ({{before|after}} optimizations)
+; CHECK-DAG: 2 instcount - Number of non-external functions ({{before|after}} optimizations)
+; CHECK-DAG: 19 instcount - Number of instructions of all types ({{before|after}} optimizations)
 
 define void @foo(i32 %i, i32 %j, i32 %n) {
 entry:
@@ -72,4 +72,4 @@ declare void @g()
 declare void @h()
 declare void @k()
 declare void @l()
-declare void @m()
+declare void @m()
\ No newline at end of file

>From fe8e0b39407e5d81475d3ecf6c4128c8b3feb65a Mon Sep 17 00:00:00 2001
From: Inaki Arrechea <inakiarrechea at google.com>
Date: Thu, 26 Mar 2026 21:20:21 +0000
Subject: [PATCH 2/3] Removed renaming of after opt metrics to maintain
 original names

---
 .../Analysis/FunctionPropertiesAnalysis.h     |  6 +-
 llvm/include/llvm/Analysis/InstCount.h        |  6 +-
 .../Analysis/FunctionPropertiesAnalysis.cpp   | 23 ++++---
 llvm/lib/Analysis/InstCount.cpp               | 63 +++++++++----------
 llvm/lib/Passes/PassBuilderPipelines.cpp      | 12 ++--
 5 files changed, 53 insertions(+), 57 deletions(-)

diff --git a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
index 50b58b7133d36..5fe20f29c58a5 100644
--- a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
+++ b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
@@ -187,10 +187,10 @@ class FunctionPropertiesPrinterPass
 /// Statistics pass for the FunctionPropertiesAnalysis results.
 struct FunctionPropertiesStatisticsPass
     : PassInfoMixin<FunctionPropertiesStatisticsPass> {
-  explicit FunctionPropertiesStatisticsPass(bool IsBeforeOptimization = false)
-      : IsBeforeOptimization(IsBeforeOptimization) {}
+  explicit FunctionPropertiesStatisticsPass(bool IsPreOptimizations = false)
+      : IsPreOptimizations(IsPreOptimizations) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
-  bool IsBeforeOptimization;
+  bool IsPreOptimizations;
 };
 
 /// Correctly update FunctionPropertiesInfo post-inlining. A
diff --git a/llvm/include/llvm/Analysis/InstCount.h b/llvm/include/llvm/Analysis/InstCount.h
index fe03ceb680f4c..db20f31b71ba4 100644
--- a/llvm/include/llvm/Analysis/InstCount.h
+++ b/llvm/include/llvm/Analysis/InstCount.h
@@ -20,10 +20,10 @@ namespace llvm {
 class Function;
 
 struct InstCountPass : PassInfoMixin<InstCountPass> {
-  explicit InstCountPass(bool IsBeforeOptimization = false)
-      : IsBeforeOptimization(IsBeforeOptimization) {}
+  explicit InstCountPass(bool IsPreOptimizations = false)
+      : IsPreOptimizations(IsPreOptimizations) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
-  bool IsBeforeOptimization;
+  bool IsPreOptimizations;
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
index bf63f2b559f52..fa067a50c01ca 100644
--- a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
+++ b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
@@ -30,15 +30,15 @@ using namespace llvm;
 #define DEBUG_TYPE "func-properties-stats"
 
 #define FUNCTION_PROPERTY(Name, Description)                                   \
-  STATISTIC(Num##Name##BeforeOptimization,                                     \
+  STATISTIC(Num##Name##PreOptimizations,                                       \
             Description " (before optimizations)");                            \
-  STATISTIC(Num##Name##AfterOptimization, Description " (after "               \
-                                                      "optimizations)");
+  STATISTIC(Num##Name, Description " (after "                                  \
+                                   "optimizations)");
 #define DETAILED_FUNCTION_PROPERTY(Name, Description)                          \
-  STATISTIC(Num##Name##BeforeOptimization,                                     \
+  STATISTIC(Num##Name##PreOptimizations,                                       \
             Description " (before optimizations)");                            \
-  STATISTIC(Num##Name##AfterOptimization, Description " (after "               \
-                                                      "optimizations)");
+  STATISTIC(Num##Name, Description " (after "                                  \
+                                   "optimizations)");
 #include "llvm/IR/FunctionProperties.def"
 
 namespace llvm {
@@ -385,19 +385,18 @@ FunctionPropertiesStatisticsPass::run(Function &F,
   LLVM_DEBUG(dbgs() << "STATSCOUNT: running on function " << F.getName()
                     << "\n");
   auto &AnalysisResults = FAM.getResult<FunctionPropertiesAnalysis>(F);
-  if (IsBeforeOptimization) {
+  if (IsPreOptimizations) {
 #define FUNCTION_PROPERTY(Name, Description)                                   \
-  Num##Name##BeforeOptimization += AnalysisResults.Name;
+  Num##Name##PreOptimizations += AnalysisResults.Name;
 #define DETAILED_FUNCTION_PROPERTY(Name, Description)                          \
-  Num##Name##BeforeOptimization += AnalysisResults.Name;
+  Num##Name##PreOptimizations += AnalysisResults.Name;
 #include "llvm/IR/FunctionProperties.def"
 #undef FUNCTION_PROPERTY
 #undef DETAILED_FUNCTION_PROPERTY
   } else {
-#define FUNCTION_PROPERTY(Name, Description)                                   \
-  Num##Name##AfterOptimization += AnalysisResults.Name;
+#define FUNCTION_PROPERTY(Name, Description) Num##Name += AnalysisResults.Name;
 #define DETAILED_FUNCTION_PROPERTY(Name, Description)                          \
-  Num##Name##AfterOptimization += AnalysisResults.Name;
+  Num##Name += AnalysisResults.Name;
 #include "llvm/IR/FunctionProperties.def"
 #undef FUNCTION_PROPERTY
 #undef DETAILED_FUNCTION_PROPERTY
diff --git a/llvm/lib/Analysis/InstCount.cpp b/llvm/lib/Analysis/InstCount.cpp
index e65da22a57c39..6a999a1283431 100644
--- a/llvm/lib/Analysis/InstCount.cpp
+++ b/llvm/lib/Analysis/InstCount.cpp
@@ -21,35 +21,33 @@ using namespace llvm;
 
 #define DEBUG_TYPE "instcount"
 
-STATISTIC(TotalInstsBeforeOptimization,
+STATISTIC(TotalInstsPreOptimizations,
           "Number of instructions of all types (before optimizations)");
-STATISTIC(TotalInstsAfterOptimization,
+STATISTIC(TotalInsts,
           "Number of instructions of all types (after optimizations)");
-STATISTIC(TotalBlocksBeforeOptimization,
+STATISTIC(TotalBlocksPreOptimizations,
           "Number of basic blocks (before optimizations)");
-STATISTIC(TotalBlocksAfterOptimization,
-          "Number of basic blocks (after optimizations)");
-STATISTIC(TotalFuncsBeforeOptimization,
+STATISTIC(TotalBlocks, "Number of basic blocks (after optimizations)");
+STATISTIC(TotalFuncsPreOptimizations,
           "Number of non-external functions (before optimizations)");
-STATISTIC(TotalFuncsAfterOptimization,
-          "Number of non-external functions (after optimizations)");
-STATISTIC(LargestFunctionSizeBeforeOptimization,
+STATISTIC(TotalFuncs, "Number of non-external functions (after optimizations)");
+STATISTIC(LargestFunctionSizePreOptimizations,
           "Largest number of instructions in a single function (before "
           "optimizations)");
-STATISTIC(LargestFunctionSizeAfterOptimization,
+STATISTIC(LargestFunctionSize,
           "Largest number of instructions in a single function (after "
           "optimizations)");
-STATISTIC(LargestFunctionBBCountBeforeOptimization,
+STATISTIC(LargestFunctionBBCountPreOptimizations,
           "Largest number of basic blocks in a single function (before "
           "optimizations)");
-STATISTIC(LargestFunctionBBCountAfterOptimization,
+STATISTIC(LargestFunctionBBCount,
           "Largest number of basic blocks in a single function (after "
           "optimizations)");
 
 #define HANDLE_INST(N, OPCODE, CLASS)                                          \
-  STATISTIC(Num##OPCODE##InstBeforeOptimization,                               \
+  STATISTIC(Num##OPCODE##InstPreOptimizations,                                 \
             "Number of " #OPCODE " insts (before optimizations)");             \
-  STATISTIC(Num##OPCODE##InstAfterOptimization,                                \
+  STATISTIC(Num##OPCODE##Inst,                                                 \
             "Number of " #OPCODE " insts (after optimizations)");
 
 #include "llvm/IR/Instruction.def"
@@ -57,39 +55,38 @@ STATISTIC(LargestFunctionBBCountAfterOptimization,
 namespace {
 class InstCount : public InstVisitor<InstCount> {
   friend class InstVisitor<InstCount>;
-  bool IsBeforeOptimization;
+  bool IsPreOptimizations;
 
 public:
-  InstCount(bool IsBeforeOptimization)
-      : IsBeforeOptimization(IsBeforeOptimization) {}
+  InstCount(bool IsPreOptimizations) : IsPreOptimizations(IsPreOptimizations) {}
 
   void visitFunction(Function &F) {
-    if (IsBeforeOptimization) {
-      ++TotalFuncsBeforeOptimization;
-      LargestFunctionSizeBeforeOptimization.updateMax(F.getInstructionCount());
-      LargestFunctionBBCountBeforeOptimization.updateMax(F.size());
+    if (IsPreOptimizations) {
+      ++TotalFuncsPreOptimizations;
+      LargestFunctionSizePreOptimizations.updateMax(F.getInstructionCount());
+      LargestFunctionBBCountPreOptimizations.updateMax(F.size());
     } else {
-      ++TotalFuncsAfterOptimization;
-      LargestFunctionSizeAfterOptimization.updateMax(F.getInstructionCount());
-      LargestFunctionBBCountAfterOptimization.updateMax(F.size());
+      ++TotalFuncs;
+      LargestFunctionSize.updateMax(F.getInstructionCount());
+      LargestFunctionBBCount.updateMax(F.size());
     }
   }
 
   void visitBasicBlock(BasicBlock &BB) {
-    if (IsBeforeOptimization)
-      ++TotalBlocksBeforeOptimization;
+    if (IsPreOptimizations)
+      ++TotalBlocksPreOptimizations;
     else
-      ++TotalBlocksAfterOptimization;
+      ++TotalBlocks;
   }
 
 #define HANDLE_INST(N, OPCODE, CLASS)                                          \
   void visit##OPCODE(CLASS &) {                                                \
-    if (IsBeforeOptimization) {                                                \
-      ++Num##OPCODE##InstBeforeOptimization;                                   \
-      ++TotalInstsBeforeOptimization;                                          \
+    if (IsPreOptimizations) {                                                  \
+      ++Num##OPCODE##InstPreOptimizations;                                     \
+      ++TotalInstsPreOptimizations;                                            \
     } else {                                                                   \
-      ++Num##OPCODE##InstAfterOptimization;                                    \
-      ++TotalInstsAfterOptimization;                                           \
+      ++Num##OPCODE##Inst;                                                     \
+      ++TotalInsts;                                                            \
     }                                                                          \
   }
 
@@ -106,7 +103,7 @@ PreservedAnalyses InstCountPass::run(Function &F,
                                      FunctionAnalysisManager &FAM) {
   LLVM_DEBUG(dbgs() << "INSTCOUNT: running on function " << F.getName()
                     << "\n");
-  InstCount(this->IsBeforeOptimization).visit(F);
+  InstCount(this->IsPreOptimizations).visit(F);
 
   return PreservedAnalyses::all();
 }
\ No newline at end of file
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index f42bf1326a6b2..7831f64a8e48c 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -418,13 +418,13 @@ void PassBuilder::invokePipelineEarlySimplificationEPCallbacks(
 
 // Helper to add AnnotationRemarksPass.
 static void addAnnotationRemarksPass(ModulePassManager &MPM,
-                                     bool IsBeforeOptimization = false) {
+                                     bool IsIsPreOptimizations = false) {
   // Count the stats for InstCount and FunctionPropertiesAnalysis
-  if (IsBeforeOptimization && AreStatisticsEnabled()) {
+  if (IsIsPreOptimizations && AreStatisticsEnabled()) {
     MPM.addPass(
-        createModuleToFunctionPassAdaptor(InstCountPass(IsBeforeOptimization)));
+        createModuleToFunctionPassAdaptor(InstCountPass(IsIsPreOptimizations)));
     MPM.addPass(createModuleToFunctionPassAdaptor(
-        FunctionPropertiesStatisticsPass(IsBeforeOptimization)));
+        FunctionPropertiesStatisticsPass(IsIsPreOptimizations)));
     return;
   }
 
@@ -432,9 +432,9 @@ static void addAnnotationRemarksPass(ModulePassManager &MPM,
 
   if (AreStatisticsEnabled()) {
     MPM.addPass(
-        createModuleToFunctionPassAdaptor(InstCountPass(IsBeforeOptimization)));
+        createModuleToFunctionPassAdaptor(InstCountPass(IsIsPreOptimizations)));
     MPM.addPass(createModuleToFunctionPassAdaptor(
-        FunctionPropertiesStatisticsPass(IsBeforeOptimization)));
+        FunctionPropertiesStatisticsPass(IsIsPreOptimizations)));
   }
 }
 

>From c55b6af44dd0c297b2816fd2013906f1c027921a Mon Sep 17 00:00:00 2001
From: Inaki Arrechea <inakiarrechea at google.com>
Date: Fri, 27 Mar 2026 19:54:15 +0000
Subject: [PATCH 3/3] Refactor passes, separating instructionCounter passes
 from addAnnotationRemarksPass

---
 llvm/lib/Analysis/InstCount.cpp               |  2 +-
 llvm/lib/Passes/PassBuilderPipelines.cpp      | 73 +++++++++++--------
 .../func-properties-analysis-diff.ll          |  2 +-
 .../func-properties-analysis.ll               |  2 +-
 .../test/Analysis/InstCount/instcount-diff.ll |  2 +-
 llvm/test/Analysis/InstCount/instcount.ll     |  2 +-
 6 files changed, 47 insertions(+), 36 deletions(-)

diff --git a/llvm/lib/Analysis/InstCount.cpp b/llvm/lib/Analysis/InstCount.cpp
index 6a999a1283431..e504ea1866e24 100644
--- a/llvm/lib/Analysis/InstCount.cpp
+++ b/llvm/lib/Analysis/InstCount.cpp
@@ -106,4 +106,4 @@ PreservedAnalyses InstCountPass::run(Function &F,
   InstCount(this->IsPreOptimizations).visit(F);
 
   return PreservedAnalyses::all();
-}
\ No newline at end of file
+}
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 7831f64a8e48c..09ecc10121cbf 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -416,27 +416,22 @@ void PassBuilder::invokePipelineEarlySimplificationEPCallbacks(
     C(MPM, Level, Phase);
 }
 
-// Helper to add AnnotationRemarksPass.
-static void addAnnotationRemarksPass(ModulePassManager &MPM,
-                                     bool IsIsPreOptimizations = false) {
-  // Count the stats for InstCount and FunctionPropertiesAnalysis
-  if (IsIsPreOptimizations && AreStatisticsEnabled()) {
-    MPM.addPass(
-        createModuleToFunctionPassAdaptor(InstCountPass(IsIsPreOptimizations)));
-    MPM.addPass(createModuleToFunctionPassAdaptor(
-        FunctionPropertiesStatisticsPass(IsIsPreOptimizations)));
-    return;
-  }
-
-  MPM.addPass(createModuleToFunctionPassAdaptor(AnnotationRemarksPass()));
-
+// Count the stats for InstCount and FunctionPropertiesAnalysis. This is used in
+// both the pre-optimization and post-optimization pipelines for comparison
+// purposes.
+static void instructionCountersPass(ModulePassManager &MPM,
+                                    bool IsPreOptimizations) {
   if (AreStatisticsEnabled()) {
     MPM.addPass(
-        createModuleToFunctionPassAdaptor(InstCountPass(IsIsPreOptimizations)));
+        createModuleToFunctionPassAdaptor(InstCountPass(IsPreOptimizations)));
     MPM.addPass(createModuleToFunctionPassAdaptor(
-        FunctionPropertiesStatisticsPass(IsIsPreOptimizations)));
+        FunctionPropertiesStatisticsPass(IsPreOptimizations)));
   }
 }
+// Helper to add AnnotationRemarksPass.
+static void addAnnotationRemarksPass(ModulePassManager &MPM) {
+  MPM.addPass(createModuleToFunctionPassAdaptor(AnnotationRemarksPass()));
+}
 
 // Helper to check if the current compilation phase is preparing for LTO
 static bool isLTOPreLink(ThinOrFullLTOPhase Phase) {
@@ -1730,9 +1725,7 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
     return buildO0DefaultPipeline(Level, Phase);
 
   ModulePassManager MPM;
-  // Emit annotation remarks. Must go at the end of the pipeline to see the
-  // final state of the IR.
-  addAnnotationRemarksPass(MPM, true);
+  instructionCountersPass(MPM, true);
 
   // Currently this pipeline is only invoked in an LTO pre link pass or when we
   // are not running LTO. If that changes the below checks may need updating.
@@ -1766,11 +1759,14 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
       PGOOpt->Action == PGOOptions::SampleUse)
     MPM.addPass(PseudoProbeUpdatePass());
 
+  // Emit annotation remarks.
+  addAnnotationRemarksPass(MPM);
+
   if (isLTOPreLink(Phase))
     addRequiredLTOPreLinkPasses(MPM);
 
-  // Emit annotation remarks.
-  addAnnotationRemarksPass(MPM);
+  // Count instruction types after optimization
+  instructionCountersPass(MPM, false);
 
   return MPM;
 }
@@ -1780,7 +1776,7 @@ PassBuilder::buildFatLTODefaultPipeline(OptimizationLevel Level, bool ThinLTO,
                                         bool EmitSummary) {
   ModulePassManager MPM;
 
-  addAnnotationRemarksPass(MPM, true);
+  instructionCountersPass(MPM, true);
 
   if (ThinLTO)
     MPM.addPass(buildThinLTOPreLinkDefaultPipeline(Level));
@@ -1821,9 +1817,12 @@ PassBuilder::buildFatLTODefaultPipeline(OptimizationLevel Level, bool ThinLTO,
     // otherwise, just use module optimization
     MPM.addPass(
         buildModuleOptimizationPipeline(Level, ThinOrFullLTOPhase::None));
+    // Emit annotation remarks.
+    addAnnotationRemarksPass(MPM);
   }
-  // Emit annotation remarks.
-  addAnnotationRemarksPass(MPM);
+
+  // Count instruction types after optimization
+  instructionCountersPass(MPM, false);
 
   return MPM;
 }
@@ -1835,7 +1834,7 @@ PassBuilder::buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level) {
 
   ModulePassManager MPM;
 
-  addAnnotationRemarksPass(MPM, true);
+  instructionCountersPass(MPM, true);
 
   // Convert @llvm.global.annotations to !annotation metadata.
   MPM.addPass(Annotation2MetadataPass());
@@ -1884,11 +1883,14 @@ PassBuilder::buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level) {
   invokeOptimizerLastEPCallbacks(MPM, Level,
                                  /*Phase=*/ThinOrFullLTOPhase::ThinLTOPreLink);
 
-  addRequiredLTOPreLinkPasses(MPM);
-
   // Emit annotation remarks.
   addAnnotationRemarksPass(MPM);
 
+  addRequiredLTOPreLinkPasses(MPM);
+
+  // Count instruction types after optimization
+  instructionCountersPass(MPM, false);
+
   return MPM;
 }
 
@@ -1896,7 +1898,7 @@ ModulePassManager PassBuilder::buildThinLTODefaultPipeline(
     OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary) {
   ModulePassManager MPM;
 
-  addAnnotationRemarksPass(MPM, true);
+  instructionCountersPass(MPM, true);
 
   // If we are invoking this without a summary index noting that we are linking
   // with a library containing the necessary APIs, remove any MemProf related
@@ -1947,7 +1949,7 @@ ModulePassManager PassBuilder::buildThinLTODefaultPipeline(
     MPM.addPass(EliminateAvailableExternallyPass());
     MPM.addPass(GlobalDCEPass());
 
-    addAnnotationRemarksPass(MPM, false);
+    instructionCountersPass(MPM, false);
     return MPM;
   }
   if (!UseCtxProfile.empty()) {
@@ -1965,6 +1967,9 @@ ModulePassManager PassBuilder::buildThinLTODefaultPipeline(
   // Emit annotation remarks.
   addAnnotationRemarksPass(MPM);
 
+  // Count instruction types after optimization
+  instructionCountersPass(MPM, false);
+
   return MPM;
 }
 
@@ -1980,7 +1985,7 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
                                      ModuleSummaryIndex *ExportSummary) {
   ModulePassManager MPM;
 
-  addAnnotationRemarksPass(MPM, true);
+  instructionCountersPass(MPM, true);
 
   invokeFullLinkTimeOptimizationEarlyEPCallbacks(MPM, Level);
 
@@ -2344,6 +2349,9 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
   // Emit annotation remarks.
   addAnnotationRemarksPass(MPM);
 
+  // Count instruction types after optimization
+  instructionCountersPass(MPM, false);
+
   return MPM;
 }
 
@@ -2355,7 +2363,7 @@ PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
 
   ModulePassManager MPM;
 
-  addAnnotationRemarksPass(MPM, true);
+  instructionCountersPass(MPM, true);
 
   // Perform pseudo probe instrumentation in O0 mode. This is for the
   // consistency between different build modes. For example, a LTO build can be
@@ -2470,6 +2478,9 @@ PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
   // Emit annotation remarks.
   addAnnotationRemarksPass(MPM);
 
+  // Count instruction types after optimization
+  instructionCountersPass(MPM, false);
+
   return MPM;
 }
 
diff --git a/llvm/test/Analysis/FunctionPropertiesAnalysis/func-properties-analysis-diff.ll b/llvm/test/Analysis/FunctionPropertiesAnalysis/func-properties-analysis-diff.ll
index 40dc0271faa77..12f342495b07f 100644
--- a/llvm/test/Analysis/FunctionPropertiesAnalysis/func-properties-analysis-diff.ll
+++ b/llvm/test/Analysis/FunctionPropertiesAnalysis/func-properties-analysis-diff.ll
@@ -22,4 +22,4 @@ else:
 end:
   %phi = phi i32 [ 1, %then ], [ 2, %else ]
   ret i32 %phi
-}
\ No newline at end of file
+}
diff --git a/llvm/test/Analysis/FunctionPropertiesAnalysis/func-properties-analysis.ll b/llvm/test/Analysis/FunctionPropertiesAnalysis/func-properties-analysis.ll
index 45370b47e833d..6415b02b763a0 100644
--- a/llvm/test/Analysis/FunctionPropertiesAnalysis/func-properties-analysis.ll
+++ b/llvm/test/Analysis/FunctionPropertiesAnalysis/func-properties-analysis.ll
@@ -67,4 +67,4 @@ declare void @g()
 declare void @h()
 declare void @k()
 declare void @l()
-declare void @m()
\ No newline at end of file
+declare void @m()
diff --git a/llvm/test/Analysis/InstCount/instcount-diff.ll b/llvm/test/Analysis/InstCount/instcount-diff.ll
index 5096e21f2b668..fdfc56726d902 100644
--- a/llvm/test/Analysis/InstCount/instcount-diff.ll
+++ b/llvm/test/Analysis/InstCount/instcount-diff.ll
@@ -22,4 +22,4 @@ else:
 end:
   %phi = phi i32 [ 1, %then ], [ 2, %else ]
   ret i32 %phi
-}
\ No newline at end of file
+}
diff --git a/llvm/test/Analysis/InstCount/instcount.ll b/llvm/test/Analysis/InstCount/instcount.ll
index df53527798efc..dbe4cba409d3f 100644
--- a/llvm/test/Analysis/InstCount/instcount.ll
+++ b/llvm/test/Analysis/InstCount/instcount.ll
@@ -72,4 +72,4 @@ declare void @g()
 declare void @h()
 declare void @k()
 declare void @l()
-declare void @m()
\ No newline at end of file
+declare void @m()



More information about the llvm-commits mailing list