[all-commits] [llvm/llvm-project] bfcb2c: [llvm-profgen] Decouple artificial branch from LBR...
ictwanglei via All-commits
all-commits at lists.llvm.org
Thu Apr 28 16:08:17 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: bfcb2c1119d902108a861448937bf4babb6951fb
https://github.com/llvm/llvm-project/commit/bfcb2c1119d902108a861448937bf4babb6951fb
Author: wlei <wlei at fb.com>
Date: 2022-04-28 (Thu, 28 Apr 2022)
Changed paths:
M llvm/test/tools/llvm-profgen/Inputs/cs-interrupt.perfscript
M llvm/test/tools/llvm-profgen/callback-external-addr.test
M llvm/test/tools/llvm-profgen/cs-interrupt.test
M llvm/test/tools/llvm-profgen/inline-noprobe2.test
M llvm/tools/llvm-profgen/PerfReader.cpp
M llvm/tools/llvm-profgen/PerfReader.h
M llvm/tools/llvm-profgen/ProfileGenerator.cpp
M llvm/tools/llvm-profgen/ProfileGenerator.h
M llvm/tools/llvm-profgen/ProfiledBinary.cpp
Log Message:
-----------
[llvm-profgen] Decouple artificial branch from LBR parser and fix external address related issues
This patch is fixing two issues for both CS and non-CS.
1) For external-call-internal, the head samples of the the internal function should be recorded.
2) avoid ignoring LBR after meeting the interrupt branch for CS profile
LBR parser is shared between CS and non-CS, we found it's error-prone while dealing with artificial branch inside LBR parser. Since artificial branch is mainly used for CS profile unwinding, this patch tries to simplify LBR parser by decoupling artificial branch code from it, the concept of artificial branch is removed and split into two transitional branches(internal-to-external, external-to-internal). Then we leave all the processing of external branch to unwinder.
Specifically for unwinder, remembering that we introduce external frame in https://reviews.llvm.org/D115550. We can just take external address as a regular address and reuse current unwind function(unwindCall, unwindReturn). For a normal case, the external frame will match an external LBR, and it will be filtered out by `unwindLinear` without losing any context.
The data also shows that the interrupt or standalone LBR pattern(unpaired case) does exist, we choose to handle it by clearing the call stack and keeping unwinding. Here we leverage checking in `unwindLinear`, because a standalone LBR, no matter its type, since it doesn’t have other part to pair, it will eventually cause a wrong linear range, like [external, internal], [internal, external]. Then set the state to invalid there.
Reviewed By: hoy, wenlei
Differential Revision: https://reviews.llvm.org/D118177
More information about the All-commits
mailing list