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.