Revert "Changed stat passes to count instructions before and after optimizations (#188837)" (#195113)
This reverts commit ea8554e35b.
Causes compile time regressions on large IR with stats enabled.
This commit is contained in:
@@ -185,14 +185,8 @@ public:
|
||||
};
|
||||
|
||||
/// Statistics pass for the FunctionPropertiesAnalysis results.
|
||||
class FunctionPropertiesStatisticsPass
|
||||
: public PassInfoMixin<FunctionPropertiesStatisticsPass> {
|
||||
bool IsPreOptimization;
|
||||
|
||||
public:
|
||||
explicit FunctionPropertiesStatisticsPass(bool IsPreOptimization = false)
|
||||
: IsPreOptimization(IsPreOptimization) {}
|
||||
|
||||
struct FunctionPropertiesStatisticsPass
|
||||
: PassInfoMixin<FunctionPropertiesStatisticsPass> {
|
||||
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
|
||||
|
||||
static bool isRequired() { return true; }
|
||||
|
||||
@@ -19,14 +19,8 @@ namespace llvm {
|
||||
|
||||
class Function;
|
||||
|
||||
class InstCountPass : public PassInfoMixin<InstCountPass> {
|
||||
bool IsPreOptimization;
|
||||
|
||||
public:
|
||||
explicit InstCountPass(bool IsPreOptimization = false)
|
||||
: IsPreOptimization(IsPreOptimization) {}
|
||||
|
||||
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
|
||||
struct InstCountPass : PassInfoMixin<InstCountPass> {
|
||||
PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
|
||||
|
||||
static bool isRequired() { return true; }
|
||||
};
|
||||
|
||||
@@ -29,13 +29,8 @@ using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "func-properties-stats"
|
||||
|
||||
#define FUNCTION_PROPERTY(Name, Description) \
|
||||
STATISTIC(Num##Name##PreOptimization, \
|
||||
Description " (before optimizations)"); \
|
||||
STATISTIC(Num##Name, Description);
|
||||
#define FUNCTION_PROPERTY(Name, Description) STATISTIC(Num##Name, Description);
|
||||
#define DETAILED_FUNCTION_PROPERTY(Name, Description) \
|
||||
STATISTIC(Num##Name##PreOptimization, \
|
||||
Description " (before optimizations)"); \
|
||||
STATISTIC(Num##Name, Description);
|
||||
#include "llvm/IR/FunctionProperties.def"
|
||||
|
||||
@@ -383,22 +378,11 @@ FunctionPropertiesStatisticsPass::run(Function &F,
|
||||
LLVM_DEBUG(dbgs() << "STATSCOUNT: running on function " << F.getName()
|
||||
<< "\n");
|
||||
auto &AnalysisResults = FAM.getResult<FunctionPropertiesAnalysis>(F);
|
||||
if (IsPreOptimization) {
|
||||
#define FUNCTION_PROPERTY(Name, Description) \
|
||||
Num##Name##PreOptimization += AnalysisResults.Name;
|
||||
#define DETAILED_FUNCTION_PROPERTY(Name, Description) \
|
||||
Num##Name##PreOptimization += AnalysisResults.Name;
|
||||
#include "llvm/IR/FunctionProperties.def"
|
||||
#undef FUNCTION_PROPERTY
|
||||
#undef DETAILED_FUNCTION_PROPERTY
|
||||
} else {
|
||||
|
||||
#define FUNCTION_PROPERTY(Name, Description) Num##Name += AnalysisResults.Name;
|
||||
#define DETAILED_FUNCTION_PROPERTY(Name, Description) \
|
||||
Num##Name += AnalysisResults.Name;
|
||||
#include "llvm/IR/FunctionProperties.def"
|
||||
#undef FUNCTION_PROPERTY
|
||||
#undef DETAILED_FUNCTION_PROPERTY
|
||||
}
|
||||
|
||||
return PreservedAnalyses::all();
|
||||
}
|
||||
|
||||
@@ -21,29 +21,15 @@ using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "instcount"
|
||||
|
||||
STATISTIC(TotalInstsPreOptimization,
|
||||
"Number of instructions of all types (before optimizations)");
|
||||
STATISTIC(TotalInsts, "Number of instructions of all types");
|
||||
STATISTIC(TotalBlocksPreOptimization,
|
||||
"Number of basic blocks (before optimizations)");
|
||||
STATISTIC(TotalInsts, "Number of instructions (of all types)");
|
||||
STATISTIC(TotalBlocks, "Number of basic blocks");
|
||||
STATISTIC(TotalFuncsPreOptimization,
|
||||
"Number of non-external functions (before optimizations)");
|
||||
STATISTIC(TotalFuncs, "Number of non-external functions");
|
||||
STATISTIC(LargestFunctionSizePreOptimization,
|
||||
"Largest number of instructions in a single function (before "
|
||||
"optimizations)");
|
||||
STATISTIC(LargestFunctionSize,
|
||||
"Largest number of instructions in a single function");
|
||||
STATISTIC(LargestFunctionBBCountPreOptimization,
|
||||
"Largest number of basic blocks in a single function (before "
|
||||
"optimizations)");
|
||||
STATISTIC(LargestFunctionBBCount,
|
||||
"Largest number of basic blocks in a single function");
|
||||
|
||||
#define HANDLE_INST(N, OPCODE, CLASS) \
|
||||
STATISTIC(Num##OPCODE##InstPreOptimization, \
|
||||
"Number of " #OPCODE " insts (before optimizations)"); \
|
||||
STATISTIC(Num##OPCODE##Inst, "Number of " #OPCODE " insts");
|
||||
|
||||
#include "llvm/IR/Instruction.def"
|
||||
@@ -51,39 +37,18 @@ STATISTIC(LargestFunctionBBCount,
|
||||
namespace {
|
||||
class InstCount : public InstVisitor<InstCount> {
|
||||
friend class InstVisitor<InstCount>;
|
||||
bool IsPreOptimization;
|
||||
|
||||
public:
|
||||
InstCount(bool IsPreOptimization) : IsPreOptimization(IsPreOptimization) {}
|
||||
|
||||
void visitFunction(Function &F) {
|
||||
if (IsPreOptimization) {
|
||||
++TotalFuncsPreOptimization;
|
||||
LargestFunctionSizePreOptimization.updateMax(F.getInstructionCount());
|
||||
LargestFunctionBBCountPreOptimization.updateMax(F.size());
|
||||
} else {
|
||||
++TotalFuncs;
|
||||
LargestFunctionSize.updateMax(F.getInstructionCount());
|
||||
LargestFunctionBBCount.updateMax(F.size());
|
||||
}
|
||||
}
|
||||
|
||||
void visitBasicBlock(BasicBlock &BB) {
|
||||
if (IsPreOptimization)
|
||||
++TotalBlocksPreOptimization;
|
||||
else
|
||||
++TotalBlocks;
|
||||
++TotalFuncs;
|
||||
LargestFunctionSize.updateMax(F.getInstructionCount());
|
||||
LargestFunctionBBCount.updateMax(F.size());
|
||||
}
|
||||
void visitBasicBlock(BasicBlock &BB) { ++TotalBlocks; }
|
||||
|
||||
#define HANDLE_INST(N, OPCODE, CLASS) \
|
||||
void visit##OPCODE(CLASS &) { \
|
||||
if (IsPreOptimization) { \
|
||||
++Num##OPCODE##InstPreOptimization; \
|
||||
++TotalInstsPreOptimization; \
|
||||
} else { \
|
||||
++Num##OPCODE##Inst; \
|
||||
++TotalInsts; \
|
||||
} \
|
||||
++Num##OPCODE##Inst; \
|
||||
++TotalInsts; \
|
||||
}
|
||||
|
||||
#include "llvm/IR/Instruction.def"
|
||||
@@ -99,7 +64,7 @@ PreservedAnalyses InstCountPass::run(Function &F,
|
||||
FunctionAnalysisManager &FAM) {
|
||||
LLVM_DEBUG(dbgs() << "INSTCOUNT: running on function " << F.getName()
|
||||
<< "\n");
|
||||
InstCount(this->IsPreOptimization).visit(F);
|
||||
InstCount().visit(F);
|
||||
|
||||
return PreservedAnalyses::all();
|
||||
}
|
||||
|
||||
@@ -814,17 +814,6 @@ Expected<bool> parseLintOptions(StringRef Params) {
|
||||
"LintPass");
|
||||
}
|
||||
|
||||
/// Parser of parameters for FunctionPropertiesStatistics pass.
|
||||
Expected<bool> parseFunctionPropertiesStatisticsOptions(StringRef Params) {
|
||||
return PassBuilder::parseSinglePassOption(Params, "pre-opt",
|
||||
"FunctionPropertiesStatisticsPass");
|
||||
}
|
||||
|
||||
/// Parser of parameters for InstCount pass.
|
||||
Expected<bool> parseInstCountOptions(StringRef Params) {
|
||||
return PassBuilder::parseSinglePassOption(Params, "pre-opt", "InstCountPass");
|
||||
}
|
||||
|
||||
/// Parser of parameters for LoopUnroll pass.
|
||||
Expected<LoopUnrollOptions> parseLoopUnrollOptions(StringRef Params) {
|
||||
LoopUnrollOptions UnrollOpts;
|
||||
|
||||
@@ -413,19 +413,15 @@ void PassBuilder::invokePipelineEarlySimplificationEPCallbacks(
|
||||
C(MPM, Level, Phase);
|
||||
}
|
||||
|
||||
// Get IR stats with InstCount and FunctionPropertiesAnalysis.
|
||||
static void instructionCountersPass(ModulePassManager &MPM,
|
||||
bool IsPreOptimization) {
|
||||
if (AreStatisticsEnabled()) {
|
||||
MPM.addPass(
|
||||
createModuleToFunctionPassAdaptor(InstCountPass(IsPreOptimization)));
|
||||
MPM.addPass(createModuleToFunctionPassAdaptor(
|
||||
FunctionPropertiesStatisticsPass(IsPreOptimization)));
|
||||
}
|
||||
}
|
||||
// Helper to add AnnotationRemarksPass.
|
||||
static void addAnnotationRemarksPass(ModulePassManager &MPM) {
|
||||
MPM.addPass(createModuleToFunctionPassAdaptor(AnnotationRemarksPass()));
|
||||
// Count the stats for InstCount and FunctionPropertiesAnalysis
|
||||
if (AreStatisticsEnabled()) {
|
||||
MPM.addPass(createModuleToFunctionPassAdaptor(InstCountPass()));
|
||||
MPM.addPass(
|
||||
createModuleToFunctionPassAdaptor(FunctionPropertiesStatisticsPass()));
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to check if the current compilation phase is preparing for LTO
|
||||
@@ -1714,7 +1710,6 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
|
||||
return buildO0DefaultPipeline(Level, Phase);
|
||||
|
||||
ModulePassManager MPM;
|
||||
instructionCountersPass(MPM, /*IsPreOptimization=*/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.
|
||||
@@ -1753,9 +1748,6 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
|
||||
|
||||
if (isLTOPreLink(Phase))
|
||||
addRequiredLTOPreLinkPasses(MPM);
|
||||
|
||||
instructionCountersPass(MPM, /*IsPreOptimization=*/false);
|
||||
|
||||
return MPM;
|
||||
}
|
||||
|
||||
@@ -1763,9 +1755,6 @@ ModulePassManager
|
||||
PassBuilder::buildFatLTODefaultPipeline(OptimizationLevel Level, bool ThinLTO,
|
||||
bool EmitSummary) {
|
||||
ModulePassManager MPM;
|
||||
|
||||
instructionCountersPass(MPM, /*IsPreOptimization=*/true);
|
||||
|
||||
if (ThinLTO)
|
||||
MPM.addPass(buildThinLTOPreLinkDefaultPipeline(Level));
|
||||
else
|
||||
@@ -1807,9 +1796,6 @@ PassBuilder::buildFatLTODefaultPipeline(OptimizationLevel Level, bool ThinLTO,
|
||||
// Emit annotation remarks.
|
||||
addAnnotationRemarksPass(MPM);
|
||||
}
|
||||
|
||||
instructionCountersPass(MPM, /*IsPreOptimization=*/false);
|
||||
|
||||
return MPM;
|
||||
}
|
||||
|
||||
@@ -1820,8 +1806,6 @@ PassBuilder::buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level) {
|
||||
|
||||
ModulePassManager MPM;
|
||||
|
||||
instructionCountersPass(MPM, /*IsPreOptimization=*/true);
|
||||
|
||||
// Convert @llvm.global.annotations to !annotation metadata.
|
||||
MPM.addPass(Annotation2MetadataPass());
|
||||
|
||||
@@ -1874,8 +1858,6 @@ PassBuilder::buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level) {
|
||||
|
||||
addRequiredLTOPreLinkPasses(MPM);
|
||||
|
||||
instructionCountersPass(MPM, /*IsPreOptimization=*/false);
|
||||
|
||||
return MPM;
|
||||
}
|
||||
|
||||
@@ -1883,8 +1865,6 @@ ModulePassManager PassBuilder::buildThinLTODefaultPipeline(
|
||||
OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary) {
|
||||
ModulePassManager MPM;
|
||||
|
||||
instructionCountersPass(MPM, /*IsPreOptimization=*/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.
|
||||
@@ -1932,8 +1912,6 @@ ModulePassManager PassBuilder::buildThinLTODefaultPipeline(
|
||||
// globals in the object file.
|
||||
MPM.addPass(EliminateAvailableExternallyPass());
|
||||
MPM.addPass(GlobalDCEPass());
|
||||
|
||||
instructionCountersPass(MPM, /*IsPreOptimization=*/false);
|
||||
return MPM;
|
||||
}
|
||||
if (!UseCtxProfile.empty()) {
|
||||
@@ -1951,8 +1929,6 @@ ModulePassManager PassBuilder::buildThinLTODefaultPipeline(
|
||||
// Emit annotation remarks.
|
||||
addAnnotationRemarksPass(MPM);
|
||||
|
||||
instructionCountersPass(MPM, /*IsPreOptimization=*/false);
|
||||
|
||||
return MPM;
|
||||
}
|
||||
|
||||
@@ -1968,8 +1944,6 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
|
||||
ModuleSummaryIndex *ExportSummary) {
|
||||
ModulePassManager MPM;
|
||||
|
||||
instructionCountersPass(MPM, /*IsPreOptimization=*/true);
|
||||
|
||||
invokeFullLinkTimeOptimizationEarlyEPCallbacks(MPM, Level);
|
||||
|
||||
// If we are invoking this without a summary index noting that we are linking
|
||||
@@ -2327,8 +2301,6 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
|
||||
// Emit annotation remarks.
|
||||
addAnnotationRemarksPass(MPM);
|
||||
|
||||
instructionCountersPass(MPM, /*IsPreOptimization=*/false);
|
||||
|
||||
return MPM;
|
||||
}
|
||||
|
||||
@@ -2340,8 +2312,6 @@ PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
|
||||
|
||||
ModulePassManager MPM;
|
||||
|
||||
instructionCountersPass(MPM, /*IsPreOptimization=*/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
|
||||
@@ -2455,8 +2425,6 @@ PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
|
||||
// Emit annotation remarks.
|
||||
addAnnotationRemarksPass(MPM);
|
||||
|
||||
instructionCountersPass(MPM, /*IsPreOptimization=*/false);
|
||||
|
||||
return MPM;
|
||||
}
|
||||
|
||||
|
||||
@@ -448,6 +448,7 @@ FUNCTION_PASS("fix-irreducible", FixIrreduciblePass())
|
||||
FUNCTION_PASS("flatten-cfg", FlattenCFGPass())
|
||||
FUNCTION_PASS("float2int", Float2IntPass())
|
||||
FUNCTION_PASS("free-machine-function", FreeMachineFunctionPass())
|
||||
FUNCTION_PASS("func-properties-stats", FunctionPropertiesStatisticsPass())
|
||||
FUNCTION_PASS("gc-lowering", GCLoweringPass())
|
||||
FUNCTION_PASS("guard-widening", GuardWideningPass())
|
||||
FUNCTION_PASS("gvn-hoist", GVNHoistPass())
|
||||
@@ -458,6 +459,7 @@ FUNCTION_PASS("infer-address-spaces", InferAddressSpacesPass())
|
||||
FUNCTION_PASS("infer-alignment", InferAlignmentPass())
|
||||
FUNCTION_PASS("inject-tli-mappings", InjectTLIMappings())
|
||||
FUNCTION_PASS("inline-asm-prepare", InlineAsmPreparePass())
|
||||
FUNCTION_PASS("instcount", InstCountPass())
|
||||
FUNCTION_PASS("instnamer", InstructionNamerPass())
|
||||
FUNCTION_PASS("instsimplify", InstSimplifyPass())
|
||||
FUNCTION_PASS("interleaved-access", InterleavedAccessPass(*TM))
|
||||
@@ -592,13 +594,6 @@ FUNCTION_PASS_WITH_PARAMS(
|
||||
"ee-instrument", "EntryExitInstrumenterPass",
|
||||
[](bool PostInlining) { return EntryExitInstrumenterPass(PostInlining); },
|
||||
parseEntryExitInstrumenterPassOptions, "post-inline")
|
||||
FUNCTION_PASS_WITH_PARAMS(
|
||||
"func-properties-stats",
|
||||
"FunctionPropertiesStatisticsPass",
|
||||
[](bool IsPreOptimizations) {
|
||||
return FunctionPropertiesStatisticsPass(IsPreOptimizations);
|
||||
},
|
||||
parseFunctionPropertiesStatisticsOptions, "pre-opt")
|
||||
FUNCTION_PASS_WITH_PARAMS(
|
||||
"function-simplification", "",
|
||||
[this](OptimizationLevel OL) {
|
||||
@@ -622,12 +617,6 @@ FUNCTION_PASS_WITH_PARAMS(
|
||||
[](InstCombineOptions Opts) { return InstCombinePass(Opts); },
|
||||
parseInstCombineOptions,
|
||||
"no-verify-fixpoint;verify-fixpoint;max-iterations=N")
|
||||
FUNCTION_PASS_WITH_PARAMS(
|
||||
"instcount", "InstCountPass",
|
||||
[](bool IsPreOptimizations) {
|
||||
return InstCountPass(IsPreOptimizations);
|
||||
},
|
||||
parseInstCountOptions, "pre-opt")
|
||||
FUNCTION_PASS_WITH_PARAMS(
|
||||
"lint", "LintPass",
|
||||
[](bool AbortOnError) { return LintPass(AbortOnError); }, parseLintOptions,
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
; REQUIRES: asserts
|
||||
; RUN: opt -stats -enable-detailed-function-properties -disable-output -passes='func-properties-stats<pre-opt>' < %s 2>&1 | FileCheck %s --check-prefix=PRE
|
||||
; RUN: opt -stats -enable-detailed-function-properties -disable-output -passes='func-properties-stats' < %s 2>&1 | FileCheck %s --check-prefixes=POSTNOOPT
|
||||
; RUN: opt -stats -enable-detailed-function-properties -disable-output -O0 < %s 2>&1 | FileCheck %s --check-prefixes=PRE,POSTNOOPT
|
||||
; RUN: opt -stats -enable-detailed-function-properties -disable-output -O3 < %s 2>&1 | FileCheck %s --check-prefixes=PRE,POST
|
||||
; RUN: opt -stats -enable-detailed-function-properties -disable-output -passes='lto<O3>' < %s 2>&1 | FileCheck %s --check-prefixes=PRE,POST
|
||||
; RUN: opt -stats -enable-detailed-function-properties -disable-output -passes='lto-pre-link<O3>' < %s 2>&1 | FileCheck %s --check-prefixes=PRE,POST
|
||||
; RUN: opt -stats -enable-detailed-function-properties -disable-output -passes='thinlto<O3>' < %s 2>&1 | FileCheck %s --check-prefixes=PRE,POST
|
||||
; RUN: opt -stats -enable-detailed-function-properties -disable-output -passes='thinlto-pre-link<O2>' < %s 2>&1 | FileCheck %s --check-prefixes=PRE,POST
|
||||
|
||||
; --- <pre-opt> ---
|
||||
; PRE-DAG: 4 func-properties-stats - Number of basic blocks (before optimizations)
|
||||
; PRE-DAG: 5 func-properties-stats - Number of instructions (of all types) (before optimizations)
|
||||
; PRE-DAG: 4 func-properties-stats - Number of basic block successors (before optimizations)
|
||||
|
||||
; --- No <pre-opt> in pass but no optimization passes run ---
|
||||
; POSTNOOPT-DAG: 4 func-properties-stats - Number of basic blocks
|
||||
; POSTNOOPT-DAG: 5 func-properties-stats - Number of instructions (of all types)
|
||||
; POSTNOOPT-DAG: 4 func-properties-stats - Number of basic block successors
|
||||
|
||||
; --- Post optimization values ---
|
||||
; POST-DAG: 1 func-properties-stats - Number of basic blocks
|
||||
; POST-DAG: 1 func-properties-stats - Number of instructions (of all types)
|
||||
; POST-NOT: func-properties-stats - Number of basic block successors
|
||||
|
||||
define i32 @test_count() {
|
||||
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
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
; Testing with all of the below run lines that the pass gets added to the appropriate pipelines
|
||||
; REQUIRES: asserts
|
||||
; RUN: opt -stats -enable-detailed-function-properties -disable-output -passes=func-properties-stats < %s 2>&1 | FileCheck %s
|
||||
; RUN: opt -stats -enable-detailed-function-properties -disable-output -passes='thinlto<O3>' < %s 2>&1 | FileCheck %s
|
||||
; RUN: opt -stats -enable-detailed-function-properties -disable-output -passes='thinlto-pre-link<O2>' < %s 2>&1 | FileCheck %s
|
||||
; RUN: opt -stats -enable-detailed-function-properties -disable-output -passes='lto<O1>' < %s 2>&1 | FileCheck %s
|
||||
; 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
|
||||
@@ -11,6 +17,7 @@
|
||||
; CHECK-DAG: 1 func-properties-stats - Number of switch instructions
|
||||
; CHECK-DAG: 4 func-properties-stats - Number of switch successors
|
||||
|
||||
|
||||
define void @foo(i32 %i, i32 %j, i32 %n) {
|
||||
entry:
|
||||
%cmp = icmp slt i32 %i, %j
|
||||
@@ -1,5 +1,11 @@
|
||||
; REQUIRES: asserts
|
||||
; RUN: opt -stats -passes=instcount -disable-output < %s 2>&1 | FileCheck %s
|
||||
; RUN: opt -stats -passes='thinlto<O3>' -disable-output < %s 2>&1 | FileCheck %s
|
||||
; RUN: opt -stats -passes='thinlto-pre-link<O2>' -disable-output < %s 2>&1 | FileCheck %s
|
||||
; RUN: opt -stats -passes='lto<O1>' -disable-output < %s 2>&1 | FileCheck %s
|
||||
; RUN: opt -stats -passes='lto-pre-link<O2>' -disable-output < %s 2>&1 | FileCheck %s
|
||||
; 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
|
||||
@@ -11,7 +17,7 @@
|
||||
; 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: 19 instcount - Number of instructions (of all types)
|
||||
|
||||
define void @foo(i32 %i, i32 %j, i32 %n) {
|
||||
entry:
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
; REQUIRES: asserts
|
||||
; RUN: opt -stats -disable-output -passes='instcount<pre-opt>' < %s 2>&1 | FileCheck %s --check-prefix=PRE
|
||||
; RUN: opt -stats -disable-output -passes='instcount' < %s 2>&1 | FileCheck %s --check-prefixes=POSTNOOPT
|
||||
; RUN: opt -stats -disable-output -O0 < %s 2>&1 | FileCheck %s --check-prefixes=PRE,POSTNOOPT
|
||||
; RUN: opt -stats -disable-output -O3 < %s 2>&1 | FileCheck %s --check-prefixes=PRE,POST
|
||||
; RUN: opt -stats -disable-output -passes='lto<O3>' < %s 2>&1 | FileCheck %s --check-prefixes=PRE,POST
|
||||
; RUN: opt -stats -disable-output -passes='lto-pre-link<O3>' < %s 2>&1 | FileCheck %s --check-prefixes=PRE,POST
|
||||
; RUN: opt -stats -disable-output -passes='thinlto<O3>' < %s 2>&1 | FileCheck %s --check-prefixes=PRE,POST
|
||||
; RUN: opt -stats -disable-output -passes='thinlto-pre-link<O2>' < %s 2>&1 | FileCheck %s --check-prefixes=PRE,POST
|
||||
|
||||
; --- <pre-opt> ---
|
||||
; PRE-DAG: 4 instcount - Number of basic blocks (before optimizations)
|
||||
; PRE-DAG: 5 instcount - Number of instructions of all types (before optimizations)
|
||||
; PRE-DAG: 1 instcount - Number of CondBr insts (before optimizations)
|
||||
|
||||
; --- No <pre-opt> in pass but no optimization passes run ---
|
||||
; POSTNOOPT-DAG: 4 instcount - Number of basic blocks
|
||||
; POSTNOOPT-DAG: 5 instcount - Number of instructions of all types
|
||||
; POSTNOOPT-DAG: 1 instcount - Number of CondBr insts
|
||||
|
||||
; --- Post optimization values ---
|
||||
; POST-DAG: 1 instcount - Number of basic blocks
|
||||
; POST-DAG: 1 instcount - Number of instructions of all types
|
||||
; POST-NOT: instcount - Number of CondBr insts
|
||||
|
||||
define i32 @test_count() {
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user