[compiler-rt] r271349 - [profile] Fix PR/27917

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Tue May 31 16:12:13 PDT 2016


Author: davidxl
Date: Tue May 31 18:12:13 2016
New Revision: 271349

URL: http://llvm.org/viewvc/llvm-project?rev=271349&view=rev
Log:
[profile] Fix PR/27917

Skip the last (possibly) incomplete node from padding bytes.


Modified:
    compiler-rt/trunk/lib/profile/InstrProfilingValue.c

Modified: compiler-rt/trunk/lib/profile/InstrProfilingValue.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingValue.c?rev=271349&r1=271348&r2=271349&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingValue.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingValue.c Tue May 31 18:12:13 2016
@@ -111,7 +111,7 @@ static ValueProfNode *allocateOneNode(__
     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(__
     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_
   CurVNode = allocateOneNode(PData, CounterIndex, TargetValue);
   if (!CurVNode)
     return;
-
   CurVNode->Value = TargetValue;
   CurVNode->Count++;
 




More information about the llvm-commits mailing list