[PATCH] D110271: [llvm-profgen] Fix an out-of-range error during unwinding

Lei Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 22 16:49:32 PDT 2021


wlei added inline comments.


================
Comment at: llvm/tools/llvm-profgen/PerfReader.cpp:65
     uint64_t LeafAddr = State.CurrentLeafFrame->Address;
-    while (IP.Address >= Target) {
+    while (IP.Address >= Target && IP.Index != 0) {
       uint64_t PrevIP = IP.Address;
----------------
wenlei wrote:
> wenlei wrote:
> > Why do we run into such cases? Is the profile corrupted? If that's the case, it may make sense to emit a warning about corrupted profile.
> > 
> > As for the check itself, how about fold it into advance/backward, and let them return a boolean for caller to check? Index is implementation details of InstructionPoint and would be good to avoid using it from outside.  
> Actually Index==0 is still valid, the problem is we cannot "backward" from index 0. However we still want to "recordRangeCount" if this index 0 is the end of the linear range. But the fix would skip "recordRangeCount" in end of range has index 0, which looks incorrect. Or am I missing something? 
Good point, Index 0 is missed then. The while loop here did compare the IP and next IP to see if they're in the same inline context or if we reach the end(target). I think the mixed logic is a little confusing. so I separate the logic letting the while loop only for inline check and after the loop we know it's the end and record the remaining range.


BTW, some refactors is done for the address being used in switchToFrame, we can use any of the address in the range, so just use the `End`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110271/new/

https://reviews.llvm.org/D110271



More information about the llvm-commits mailing list