diff options
| author | Xinliang David Li <davidxl@google.com> | 2016-05-25 21:27:02 +0000 |
|---|---|---|
| committer | Xinliang David Li <davidxl@google.com> | 2016-05-25 21:27:02 +0000 |
| commit | 65971297a08eca1a36c5d7eab5ee5df6753eabb4 (patch) | |
| tree | 516dc27aff63b0125b09c5fcfca95414b2c5d629 /compiler-rt/lib/profile/InstrProfilingValue.c | |
| parent | fad596aa8195fb390a4ff6cdc016c26007743dfa (diff) | |
| download | bcm5719-llvm-65971297a08eca1a36c5d7eab5ee5df6753eabb4.tar.gz bcm5719-llvm-65971297a08eca1a36c5d7eab5ee5df6753eabb4.zip | |
[profile] Add early checking to bypass node pointer update
llvm-svn: 270766
Diffstat (limited to 'compiler-rt/lib/profile/InstrProfilingValue.c')
| -rw-r--r-- | compiler-rt/lib/profile/InstrProfilingValue.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler-rt/lib/profile/InstrProfilingValue.c b/compiler-rt/lib/profile/InstrProfilingValue.c index 08f91b35fd5..63b5e6fca15 100644 --- a/compiler-rt/lib/profile/InstrProfilingValue.c +++ b/compiler-rt/lib/profile/InstrProfilingValue.c @@ -103,16 +103,21 @@ static ValueProfNode *allocateOneNode(__llvm_profile_data *Data, uint32_t Index, 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; } |

