#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/PseudoProbe.h"
#include "llvm/ProfileData/SampleProfReader.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Error.h"
using namespace llvm;
using namespace sampleprof;
+static cl::opt<uint64_t> ProfileSymbolListCutOff(
+ "profile-symbol-list-cutoff", cl::Hidden, cl::init(-1), cl::ZeroOrMore,
+ cl::desc("Cutoff value about how many symbols in profile symbol list "
+ "will be used. This is very useful for performance debugging"));
+
namespace llvm {
namespace sampleprof {
SampleProfileFormat FunctionSamples::Format;
uint64_t ListSize) {
const char *ListStart = reinterpret_cast<const char *>(Data);
uint64_t Size = 0;
- while (Size < ListSize) {
+ uint64_t StrNum = 0;
+ while (Size < ListSize && StrNum < ProfileSymbolListCutOff) {
StringRef Str(ListStart + Size);
add(Str);
Size += Str.size() + 1;
+ StrNum++;
}
- if (Size != ListSize)
+ if (Size != ListSize && StrNum != ProfileSymbolListCutOff)
return sampleprof_error::malformed;
return sampleprof_error::success;
}
; RUN: llvm-profdata merge -sample -extbinary -prof-sym-list=%S/Inputs/profile-symbol-list.text %S/Inputs/profsampleacc.extbinary.afdo -o %t.symlist.afdo
; RUN: opt < %s -sample-profile -sample-profile-file=%t.symlist.afdo -profile-summary-cutoff-hot=600000 -profile-accurate-for-symsinlist -enable-new-pm=0 -S | FileCheck %s --check-prefix=PROFSYMLIST
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.symlist.afdo -profile-summary-cutoff-hot=600000 -profile-accurate-for-symsinlist -S | FileCheck %s --check-prefix=PROFSYMLIST
+; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.symlist.afdo -profile-accurate-for-symsinlist -profile-symbol-list-cutoff=2 -S | FileCheck %s --check-prefix=PSLCUTOFF2
+; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.symlist.afdo -profile-accurate-for-symsinlist -profile-symbol-list-cutoff=3 -S | FileCheck %s --check-prefix=PSLCUTOFF3
;
; If -profile-accurate-for-symsinlist and -profile-sample-accurate both present,
; -profile-sample-accurate will override -profile-accurate-for-symsinlist.
ret i32 %add, !dbg !11
}
+; Check -profile-symbol-list-cutoff=3 will include _Z3toov into profile
+; symbol list and -profile-symbol-list-cutoff=2 will not.
+; PSLCUTOFF2: define i32 @_Z3toov{{.*}}!prof ![[TOO_ID:[0-9]+]]
+; PSLCUTOFF3: define i32 @_Z3toov{{.*}}!prof ![[TOO_ID:[0-9]+]]
+define i32 @_Z3toov(i32 %x, i32 %y) #0 {
+entry:
+ %add = add nsw i32 %x, %y
+ ret i32 %add
+}
+
; Function Attrs: uwtable
define i32 @main() #0 !dbg !7 {
entry:
; CALL_SUM_IS_HOT: ![[ZERO_ID]] = !{!"function_entry_count", i64 0}
; CALL_SUM_IS_WARM: ![[NONZERO_ID]] = !{!"function_entry_count", i64 5179}
; PROFSYMLIST: ![[UNKNOWN_ID]] = !{!"function_entry_count", i64 -1}
+; PSLCUTOFF2: ![[TOO_ID]] = !{!"function_entry_count", i64 -1}
+; PSLCUTOFF3: ![[TOO_ID]] = !{!"function_entry_count", i64 0}
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5 ", isOptimized: false, emissionKind: NoDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
!1 = !DIFile(filename: "calls.cc", directory: ".")
!2 = !{}