[PATCH] D104546: [CSSPGO][llvm-profgen] Handle reurn to external transition.

Hongtao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 18 09:31:51 PDT 2021


hoy created this revision.
Herald added a subscriber: wenlei.
hoy requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104546

Files:
  llvm/tools/llvm-profgen/PerfReader.cpp


Index: llvm/tools/llvm-profgen/PerfReader.cpp
===================================================================
--- llvm/tools/llvm-profgen/PerfReader.cpp
+++ llvm/tools/llvm-profgen/PerfReader.cpp
@@ -460,6 +460,16 @@
         // 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104546.353030.patch
Type: text/x-patch
Size: 878 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210618/47bcc082/attachment.bin>


More information about the llvm-commits mailing list