Skip to content

Commit

Permalink
Make Function::getInstructionCount const
Browse files Browse the repository at this point in the history
Summary: Function::getInstructionCount can be const.

Reviewers: davidxl, paquette

Reviewed By: davidxl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D53378

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344754 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
mtrofin committed Oct 18, 2018
1 parent 14914d0 commit 4aeb7d0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/llvm/IR/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class Function : public GlobalObject, public ilist_node<Function> {
/// 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 {
Expand Down
4 changes: 2 additions & 2 deletions lib/IR/Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ LLVMContext &Function::getContext() const {
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;
Expand Down

0 comments on commit 4aeb7d0

Please sign in to comment.