diff --git a/llvm/lib/Analysis/InstCount.cpp b/llvm/lib/Analysis/InstCount.cpp index b43c9cd074b9..9e03126db7cb 100644 --- a/llvm/lib/Analysis/InstCount.cpp +++ b/llvm/lib/Analysis/InstCount.cpp @@ -24,6 +24,8 @@ using namespace llvm; 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"); #define HANDLE_INST(N, OPCODE, CLASS) \ STATISTIC(Num##OPCODE##Inst, "Number of " #OPCODE " insts"); @@ -34,7 +36,10 @@ namespace { class InstCount : public InstVisitor { friend class InstVisitor; - void visitFunction(Function &F) { ++TotalFuncs; } + void visitFunction(Function &F) { + ++TotalFuncs; + LargestFunctionSize.updateMax(F.getInstructionCount()); + } void visitBasicBlock(BasicBlock &BB) { ++TotalBlocks; } #define HANDLE_INST(N, OPCODE, CLASS) \ diff --git a/llvm/test/Other/instcount.ll b/llvm/test/Analysis/InstCount/instcount.ll similarity index 81% rename from llvm/test/Other/instcount.ll rename to llvm/test/Analysis/InstCount/instcount.ll index 931d54737195..5f60213faaf1 100644 --- a/llvm/test/Other/instcount.ll +++ b/llvm/test/Analysis/InstCount/instcount.ll @@ -7,15 +7,15 @@ ; RUN: opt -stats -O3 -disable-output < %s 2>&1 | FileCheck %s ; RUN: opt -stats -O0 -disable-output < %s 2>&1 | FileCheck %s +; CHECK-DAG: 18 instcount - Largest number of instructions in a single function ; CHECK-DAG: 8 instcount - Number of Br insts ; CHECK-DAG: 6 instcount - Number of Call insts ; CHECK-DAG: 2 instcount - Number of ICmp insts -; CHECK-DAG: 1 instcount - Number of Ret insts +; CHECK-DAG: 2 instcount - Number of Ret insts ; CHECK-DAG: 1 instcount - Number of Switch insts -; CHECK-DAG: 10 instcount - Number of basic blocks -; CHECK-DAG: 1 instcount - Number of non-external functions -; CHECK-DAG: 18 instcount - Number of instructions (of all types) - +; 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) define void @foo(i32 %i, i32 %j, i32 %n) { entry: @@ -61,6 +61,10 @@ if.end4: ret void } +define void @woo() { + ret void +} + declare void @f() declare void @g() declare void @h()