diff options
author | Hongtao Yu <hoy@fb.com> | 2021-06-18 09:30:38 -0700 |
---|---|---|
committer | Hongtao Yu <hoy@fb.com> | 2021-06-22 16:24:59 -0700 |
commit | 5c8659801a4976ef2b327f4071d98086efd42a36 (patch) | |
tree | 6f3b567e81e494b3b3b84ecd7af5fa7926ef1b1e | |
parent | 959dbd1761cddbe8c53509459dbc0463f86c1b50 (diff) | |
download | llvm-5c8659801a4976ef2b327f4071d98086efd42a36.zip llvm-5c8659801a4976ef2b327f4071d98086efd42a36.tar.gz llvm-5c8659801a4976ef2b327f4071d98086efd42a36.tar.bz2 |
[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
-rw-r--r-- | llvm/tools/llvm-profgen/PerfReader.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/tools/llvm-profgen/PerfReader.cpp b/llvm/tools/llvm-profgen/PerfReader.cpp index aaa4a06..a9805cf 100644 --- a/llvm/tools/llvm-profgen/PerfReader.cpp +++ b/llvm/tools/llvm-profgen/PerfReader.cpp @@ -460,6 +460,16 @@ bool PerfReader::extractLBRStack(TraceStream &TraceIt, // they are likely in different contexts. break; } + + if (Binary->addressIsReturn(Src)) { + // 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. + break; + } + // For transition to external code, group the Source with the next // availabe transition target. Dst = PrevTrDst; |