From 6c73b49911e29dc89d40dd95e5548d2359d53414 Mon Sep 17 00:00:00 2001 From: Dehao Chen Date: Mon, 22 Feb 2016 22:46:21 +0000 Subject: [PATCH] Set function entry count as 0 if sample profile is not found for the function. Summary: This change makes the sample profile's behavior consistent with instr profile. Reviewers: davidxl, eraman, dnovillo Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D17522 llvm-svn: 261587 --- llvm/lib/Transforms/IPO/SampleProfile.cpp | 1 + llvm/test/Transforms/SampleProfile/entry_counts.ll | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp index 9fb6fac..b863666 100644 --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -1257,6 +1257,7 @@ bool SampleProfileLoader::runOnModule(Module &M) { } bool SampleProfileLoader::runOnFunction(Function &F) { + F.setEntryCount(0); Samples = Reader->getSamplesFor(F); if (!Samples->empty()) return emitAnnotations(F); diff --git a/llvm/test/Transforms/SampleProfile/entry_counts.ll b/llvm/test/Transforms/SampleProfile/entry_counts.ll index 50cd575..6d1d431 100644 --- a/llvm/test/Transforms/SampleProfile/entry_counts.ll +++ b/llvm/test/Transforms/SampleProfile/entry_counts.ll @@ -8,6 +8,13 @@ entry: ret void, !dbg !9 } +; This function does not have profile, check if function_entry_count is 0 +; CHECK: {{.*}} = !{!"function_entry_count", i64 0} +define void @no_profile() { +entry: + ret void +} + !llvm.dbg.cu = !{!0} !llvm.module.flags = !{!6, !7} !llvm.ident = !{!8} -- 2.7.4