[PATCH] D17522: 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:39:13 PST 2016


danielcdh created this revision.
danielcdh added reviewers: davidxl, dnovillo, eraman.
danielcdh added a subscriber: llvm-commits.

This change makes the sample profile's behavior consistent with instr profile.

http://reviews.llvm.org/D17522

Files:
  lib/Transforms/IPO/SampleProfile.cpp
  test/Transforms/SampleProfile/entry_counts.ll

Index: test/Transforms/SampleProfile/entry_counts.ll
===================================================================
--- test/Transforms/SampleProfile/entry_counts.ll
+++ test/Transforms/SampleProfile/entry_counts.ll
@@ -8,6 +8,13 @@
   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}
Index: lib/Transforms/IPO/SampleProfile.cpp
===================================================================
--- lib/Transforms/IPO/SampleProfile.cpp
+++ lib/Transforms/IPO/SampleProfile.cpp
@@ -1257,6 +1257,7 @@
 }
 
 bool SampleProfileLoader::runOnFunction(Function &F) {
+  F.setEntryCount(0);
   Samples = Reader->getSamplesFor(F);
   if (!Samples->empty())
     return emitAnnotations(F);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17522.48736.patch
Type: text/x-patch
Size: 918 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160222/ebce4c1f/attachment.bin>


More information about the llvm-commits mailing list