diff options
author | Xinliang David Li <davidxl@google.com> | 2016-05-31 23:12:13 +0000 |
---|---|---|
committer | Xinliang David Li <davidxl@google.com> | 2016-05-31 23:12:13 +0000 |
commit | da1eadd571a9842beaf8dfea352ed2b7ea07bbbf (patch) | |
tree | 06aa41cc7a4598820f20e5ccceeb2f1600e77019 /lib/profile/InstrProfilingValue.c | |
parent | 965efde6608e651c6cf6501669bb3ea77647bacc (diff) |
[profile] Fix PR/27917
Skip the last (possibly) incomplete node from padding bytes.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@271349 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/profile/InstrProfilingValue.c')
-rw-r--r-- | lib/profile/InstrProfilingValue.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/profile/InstrProfilingValue.c b/lib/profile/InstrProfilingValue.c index b7d57243c..b6a982dcb 100644 --- a/lib/profile/InstrProfilingValue.c +++ b/lib/profile/InstrProfilingValue.c @@ -111,7 +111,7 @@ static ValueProfNode *allocateOneNode(__llvm_profile_data *Data, uint32_t Index, return (ValueProfNode *)calloc(1, sizeof(ValueProfNode)); /* Early check to avoid value wrapping around. */ - if (CurrentVNode >= EndVNode) { + if (CurrentVNode + 1 > EndVNode) { if (OutOfNodesWarnings++ < INSTR_PROF_MAX_VP_WARNS) { PROF_WARN("Unable to track new values: %s. " " Consider using option -mllvm -vp-counters-per-site=<n> to " @@ -122,7 +122,9 @@ static ValueProfNode *allocateOneNode(__llvm_profile_data *Data, uint32_t Index, return 0; } Node = COMPILER_RT_PTR_FETCH_ADD(ValueProfNode, CurrentVNode, 1); - if (Node >= EndVNode) + /* Due to section padding, EndVNode point to a byte which is one pass + * an incomplete VNode, so we need to skip the last incomplete node. */ + if (Node + 1 > EndVNode) return 0; return Node; @@ -201,7 +203,6 @@ __llvm_profile_instrument_target(uint64_t TargetValue, void *Data, CurVNode = allocateOneNode(PData, CounterIndex, TargetValue); if (!CurVNode) return; - CurVNode->Value = TargetValue; CurVNode->Count++; |