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 | 96dad78963aa350f5687da52af28f55a3cf1ef3c (patch) | |
| tree | cac42f30d41fc2d048f881705534fb8a95985b47 | |
| parent | cceae7feda8e33194d1a6c5963bd4114bb8d2b36 (diff) | |
| download | llvm-96dad78963aa350f5687da52af28f55a3cf1ef3c.zip llvm-96dad78963aa350f5687da52af28f55a3cf1ef3c.tar.gz llvm-96dad78963aa350f5687da52af28f55a3cf1ef3c.tar.bz2 | |
[profile] Fix PR/27917
Skip the last (possibly) incomplete node from padding bytes.
llvm-svn: 271349
| -rw-r--r-- | compiler-rt/lib/profile/InstrProfilingValue.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler-rt/lib/profile/InstrProfilingValue.c b/compiler-rt/lib/profile/InstrProfilingValue.c index b7d5724..b6a982d 100644 --- a/compiler-rt/lib/profile/InstrProfilingValue.c +++ b/compiler-rt/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++; |
