From 428b9e0627883ff2b736f191f66dfdc0ef6b48e0 Mon Sep 17 00:00:00 2001 From: Teresa Johnson Date: Fri, 24 Mar 2017 17:59:06 +0000 Subject: [PATCH] [ThinLTO] Correct counting of functions in inliner stats 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 --- .../Transforms/Utils/ImportedFunctionsInliningStatistics.cpp | 2 ++ llvm/test/Transforms/Inline/inline_stats.ll | 3 +++ 2 files changed, 5 insertions(+) diff --git a/llvm/lib/Transforms/Utils/ImportedFunctionsInliningStatistics.cpp b/llvm/lib/Transforms/Utils/ImportedFunctionsInliningStatistics.cpp index ed018bb73107..b8c12ad5ea84 100644 --- a/llvm/lib/Transforms/Utils/ImportedFunctionsInliningStatistics.cpp +++ b/llvm/lib/Transforms/Utils/ImportedFunctionsInliningStatistics.cpp @@ -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); } diff --git a/llvm/test/Transforms/Inline/inline_stats.ll b/llvm/test/Transforms/Inline/inline_stats.ll index cf0d43e9215b..bc005b6afd51 100644 --- a/llvm/test/Transforms/Inline/inline_stats.ll +++ b/llvm/test/Transforms/Inline/inline_stats.ll @@ -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 }