[llvm] r344754 - Make Function::getInstructionCount const
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 18 12:49:44 PDT 2018
Author: mtrofin
Date: Thu Oct 18 12:49:44 2018
New Revision: 344754
URL: http://llvm.org/viewvc/llvm-project?rev=344754&view=rev
Log:
Make Function::getInstructionCount const
Summary: Function::getInstructionCount can be const.
Reviewers: davidxl, paquette
Reviewed By: davidxl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D53378
Modified:
llvm/trunk/include/llvm/IR/Function.h
llvm/trunk/lib/IR/Function.cpp
Modified: llvm/trunk/include/llvm/IR/Function.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Function.h?rev=344754&r1=344753&r2=344754&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Function.h (original)
+++ llvm/trunk/include/llvm/IR/Function.h Thu Oct 18 12:49:44 2018
@@ -158,7 +158,7 @@ public:
/// Returns the number of non-debug IR instructions in this function.
/// This is equivalent to the sum of the sizes of each basic block contained
/// within this function.
- unsigned getInstructionCount();
+ unsigned getInstructionCount() const;
/// Returns the FunctionType for me.
FunctionType *getFunctionType() const {
Modified: llvm/trunk/lib/IR/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=344754&r1=344753&r2=344754&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Function.cpp (original)
+++ llvm/trunk/lib/IR/Function.cpp Thu Oct 18 12:49:44 2018
@@ -195,9 +195,9 @@ LLVMContext &Function::getContext() cons
return getType()->getContext();
}
-unsigned Function::getInstructionCount() {
+unsigned Function::getInstructionCount() const {
unsigned NumInstrs = 0;
- for (BasicBlock &BB : BasicBlocks)
+ for (const BasicBlock &BB : BasicBlocks)
NumInstrs += std::distance(BB.instructionsWithoutDebug().begin(),
BB.instructionsWithoutDebug().end());
return NumInstrs;
More information about the llvm-commits
mailing list