[llvm] r261587 - Set function entry count as 0 if sample profile is not found for the function.

Dehao Chen via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 22 14:46:21 PST 2016


Author: dehao
Date: Mon Feb 22 16:46:21 2016
New Revision: 261587

URL: http://llvm.org/viewvc/llvm-project?rev=261587&view=rev
Log:
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

Modified:
    llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
    llvm/trunk/test/Transforms/SampleProfile/entry_counts.ll

Modified: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=261587&r1=261586&r2=261587&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp Mon Feb 22 16:46:21 2016
@@ -1257,6 +1257,7 @@ bool SampleProfileLoader::runOnModule(Mo
 }
 
 bool SampleProfileLoader::runOnFunction(Function &F) {
+  F.setEntryCount(0);
   Samples = Reader->getSamplesFor(F);
   if (!Samples->empty())
     return emitAnnotations(F);

Modified: llvm/trunk/test/Transforms/SampleProfile/entry_counts.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SampleProfile/entry_counts.ll?rev=261587&r1=261586&r2=261587&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SampleProfile/entry_counts.ll (original)
+++ llvm/trunk/test/Transforms/SampleProfile/entry_counts.ll Mon Feb 22 16:46:21 2016
@@ -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}




More information about the llvm-commits mailing list