[llvm] 20ad206 - [NFC] Module::getInstructionCount() is const

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 25 12:29:29 PDT 2021


Author: Mircea Trofin
Date: 2021-03-25T12:29:19-07:00
New Revision: 20ad206b605530b827318cb242db7d6c04b273ea

URL: https://github.com/llvm/llvm-project/commit/20ad206b605530b827318cb242db7d6c04b273ea
DIFF: https://github.com/llvm/llvm-project/commit/20ad206b605530b827318cb242db7d6c04b273ea.diff

LOG: [NFC] Module::getInstructionCount() is const

Added: 
    

Modified: 
    llvm/include/llvm/IR/Module.h
    llvm/lib/IR/Module.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index 6abe67575bbf..ca8a49f10f53 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -229,7 +229,7 @@ class Module {
   /// Returns the number of non-debug IR instructions in the module.
   /// This is equivalent to the sum of the IR instruction counts of each
   /// function contained in the module.
-  unsigned getInstructionCount();
+  unsigned getInstructionCount() const;
 
   /// Get the module's original source file name. When compiling from
   /// bitcode, this is taken from a bitcode record where it was recorded.

diff  --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index b9c3663b8fa3..41666e8274d4 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -571,9 +571,9 @@ unsigned Module::getCodeViewFlag() const {
   return cast<ConstantInt>(Val->getValue())->getZExtValue();
 }
 
-unsigned Module::getInstructionCount() {
+unsigned Module::getInstructionCount() const {
   unsigned NumInstrs = 0;
-  for (Function &F : FunctionList)
+  for (const Function &F : FunctionList)
     NumInstrs += F.getInstructionCount();
   return NumInstrs;
 }


        


More information about the llvm-commits mailing list