[compiler-rt] r270766 - [profile] Add early checking to bypass node pointer update
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Wed May 25 14:27:03 PDT 2016
Author: davidxl
Date: Wed May 25 16:27:02 2016
New Revision: 270766
URL: http://llvm.org/viewvc/llvm-project?rev=270766&view=rev
Log:
[profile] Add early checking to bypass node pointer update
Modified:
compiler-rt/trunk/lib/profile/InstrProfilingValue.c
compiler-rt/trunk/test/profile/instrprof-value-prof.test
Modified: compiler-rt/trunk/lib/profile/InstrProfilingValue.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingValue.c?rev=270766&r1=270765&r2=270766&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingValue.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingValue.c Wed May 25 16:27:02 2016
@@ -103,16 +103,21 @@ static ValueProfNode *allocateOneNode(__
if (!hasStaticCounters)
return (ValueProfNode *)calloc(1, sizeof(ValueProfNode));
- Node = COMPILER_RT_PTR_FETCH_ADD(ValueProfNode, CurrentVNode, 1);
- if (Node >= EndVNode) {
+ /* Early check to avoid value wrapping around. */
+ if (CurrentVNode >= EndVNode) {
if (OutOfNodesWarnings++ < MAX_VP_WARNS) {
PROF_WARN("Unable to track new values: %s. "
- " Consider using option -mllvm -vp-counters-per-site=<n> to allocate more"
+ " Consider using option -mllvm -vp-counters-per-site=<n> to "
+ "allocate more"
" value profile counters at compile time. \n",
"Running out of static counters");
}
return 0;
}
+ Node = COMPILER_RT_PTR_FETCH_ADD(ValueProfNode, CurrentVNode, 1);
+ if (Node >= EndVNode)
+ return 0;
+
return Node;
}
Modified: compiler-rt/trunk/test/profile/instrprof-value-prof.test
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/instrprof-value-prof.test?rev=270766&r1=270765&r2=270766&view=diff
==============================================================================
--- compiler-rt/trunk/test/profile/instrprof-value-prof.test (original)
+++ compiler-rt/trunk/test/profile/instrprof-value-prof.test Wed May 25 16:27:02 2016
@@ -11,6 +11,9 @@
// RUN: llvm-profdata merge -text %t.ir.profdata -o %t.ir.proftxt
// RUN: FileCheck %S/Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.proftxt
+// RUN: %clang_profgen -O2 -mllvm -disable-vp=false -Xclang -fprofile-instrument=llvm -mllvm -vp-static-alloc=true -o %t.ir.warn %S/Inputs/instrprof-value-prof-real.c
+// RUN: env LLVM_PROFILE_FILE=%t.ir.profraw %run %t.ir.warn 2>&1 |FileCheck --check-prefix=WARNING %s
+
// IR level instrumentation with dynamic memory allocation
// RUN: %clang_profgen -O2 -mllvm -disable-vp=false -Xclang -fprofile-instrument=llvm -mllvm -vp-static-alloc=false -mllvm -vp-counters-per-site=256 -o %t.ir.dyn %S/Inputs/instrprof-value-prof-real.c
// RUN: env LLVM_PROFILE_FILE=%t.ir.dyn.profraw %run %t.ir.dyn
@@ -18,3 +21,5 @@
// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.dyn.profdata | FileCheck %S/Inputs/instrprof-value-prof-real.c
// RUN: llvm-profdata merge -text %t.ir.dyn.profdata -o %t.ir.dyn.proftxt
// RUN: FileCheck %S/Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.dyn.proftxt
+
+// WARNING: LLVM Profile Warning:
More information about the llvm-commits
mailing list