[PATCH] D61025: Add an optional arg to include/exclude synthetic profile when query hasProfileData

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 23 09:12:19 PDT 2019


davidxl created this revision.
davidxl added a reviewer: eraman.

The arg is defaulted to false as most of the users of the interface checks for branch probability data.

Synthetic profile propagation is not on by default, so this patch has no effect on default compilations.


https://reviews.llvm.org/D61025

Files:
  include/llvm/IR/Function.h


Index: include/llvm/IR/Function.h
===================================================================
--- include/llvm/IR/Function.h
+++ include/llvm/IR/Function.h
@@ -303,8 +303,14 @@
   /// Return true if the function is annotated with profile data.
   ///
   /// Presence of entry counts from a profile run implies the function has
-  /// profile annotations.
-  bool hasProfileData() const { return getEntryCount().hasValue(); }
+  /// profile annotations. If IncludeSynthetic is false, only return true
+  /// when the profile data is real.
+  bool hasProfileData(bool IncludeSynthetic = false) const {
+    auto EC = getEntryCount();
+    if (!EC.hasValue() || (EC.isSynthetic() && !IncludeSynthetic))
+      return false;
+    return true;
+  }
 
   /// Returns the set of GUIDs that needs to be imported to the function for
   /// sample PGO, to enable the same inlines as the profiled optimized binary.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61025.196266.patch
Type: text/x-patch
Size: 912 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190423/f7948680/attachment.bin>


More information about the llvm-commits mailing list