[ThinLTO] Correct counting of functions in inliner stats
authorTeresa Johnson <tejohnson@google.com>
Fri, 24 Mar 2017 17:59:06 +0000 (17:59 +0000)
committerTeresa Johnson <tejohnson@google.com>
Fri, 24 Mar 2017 17:59:06 +0000 (17:59 +0000)
Summary: Declarations need to be filtered out when counting functions.

Reviewers: eraman

Subscribers: Prazek, llvm-commits

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

llvm-svn: 298720

llvm/lib/Transforms/Utils/ImportedFunctionsInliningStatistics.cpp
llvm/test/Transforms/Inline/inline_stats.ll

index ed018bb..b8c12ad 100644 (file)
@@ -62,6 +62,8 @@ void ImportedFunctionsInliningStatistics::recordInline(const Function &Caller,
 void ImportedFunctionsInliningStatistics::setModuleInfo(const Module &M) {
   ModuleName = M.getName();
   for (const auto &F : M.functions()) {
+    if (F.isDeclaration())
+      continue;
     AllFunctions++;
     ImportedFunctions += int(F.getMetadata("thinlto_src_module") != nullptr);
   }
index cf0d43e..bc005b6 100644 (file)
@@ -36,9 +36,12 @@ define void @internal3() {
     ret void
 }
 
+declare void @external_decl()
+
 define void @external1() alwaysinline !thinlto_src_module !0 {
     call fastcc void @internal2()
     call fastcc void @external2();
+    call void @external_decl();
     ret void
 }