Skip to content

Commit 5c86598

Browse files
committed
[CSSPGO][llvm-profgen] Handle return to external transition.
In a callback case, a return from internal code, say A, to external runtime can happen. The external runtime can then call back to another internal routine, say B. Making an artificial branch that looks like a return from A to B can confuse the unwinder to treat the instruction before B as the call instruction. Reviewed By: wenlei, wmi Differential Revision: https://reviews.llvm.org/D104546
1 parent 959dbd1 commit 5c86598

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

llvm/tools/llvm-profgen/PerfReader.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,16 @@ bool PerfReader::extractLBRStack(TraceStream &TraceIt,
460460
// they are likely in different contexts.
461461
break;
462462
}
463+
464+
if (Binary->addressIsReturn(Src)) {
465+
// In a callback case, a return from internal code, say A, to external
466+
// runtime can happen. The external runtime can then call back to
467+
// another internal routine, say B. Making an artificial branch that
468+
// looks like a return from A to B can confuse the unwinder to treat
469+
// the instruction before B as the call instruction.
470+
break;
471+
}
472+
463473
// For transition to external code, group the Source with the next
464474
// availabe transition target.
465475
Dst = PrevTrDst;

0 commit comments

Comments
 (0)