[PATCH] D53378: Make Function::getInstructionCount const

Mircea Trofin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 17 08:55:49 PDT 2018


mtrofin created this revision.
mtrofin added reviewers: davidxl, paquette.
Herald added a subscriber: llvm-commits.

Function::getInstructionCount can be const.


Repository:
  rL LLVM

https://reviews.llvm.org/D53378

Files:
  include/llvm/IR/Function.h
  lib/IR/Function.cpp


Index: lib/IR/Function.cpp
===================================================================
--- lib/IR/Function.cpp
+++ lib/IR/Function.cpp
@@ -195,9 +195,9 @@
   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;
Index: include/llvm/IR/Function.h
===================================================================
--- include/llvm/IR/Function.h
+++ include/llvm/IR/Function.h
@@ -158,7 +158,7 @@
   /// 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 {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53378.170017.patch
Type: text/x-patch
Size: 1095 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181017/602fc600/attachment.bin>


More information about the llvm-commits mailing list