[PATCH] D53378: Make Function::getInstructionCount const

Mircea Trofin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 18 12:51:51 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL344754: Make Function::getInstructionCount const (authored by mtrofin, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D53378

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


Index: llvm/trunk/include/llvm/IR/Function.h
===================================================================
--- llvm/trunk/include/llvm/IR/Function.h
+++ llvm/trunk/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 {
Index: llvm/trunk/lib/IR/Function.cpp
===================================================================
--- llvm/trunk/lib/IR/Function.cpp
+++ llvm/trunk/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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53378.170110.patch
Type: text/x-patch
Size: 1161 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181018/494ba616/attachment.bin>


More information about the llvm-commits mailing list