[llvm] [BOLT] Gadget scanner: analyze functions without CFG information (PR #133461)
Anatoly Trosinenko via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 7 12:39:53 PDT 2025
================
@@ -124,6 +124,27 @@ class TrackedRegisters {
}
};
+// Without CFG, we reset gadget scanning state when encountering an
+// unconditional branch. Note that BC.MIB->isUnconditionalBranch neither
+// considers indirect branches nor annotated tail calls as unconditional.
+static bool isStateTrackingBoundary(const BinaryContext &BC,
+ const MCInst &Inst) {
----------------
atrosinenko wrote:
Taking into account your next comment and replacing `Desc.isBranch() && Desc.isBarrier()` with just `Desc.isBarrier()` made this function rather trivial, so it is possible to remove it as a separate function and "inline" into the calling function instead.
> And maybe add a high-level description of how the "NoCFG" analysis works/is different from the regular "CFG" analysis?
> That might make it easier to understand this analysis and make it more likely for other in the future to help contribute/improve it?
I added an explanation before `NoCFGPacRetAnalysis`, and realized that using unconditional branches as boundaries is only approximation and the real boundaries are labels. Thus, the "inlined" part of this function was finally removed, too :)
https://github.com/llvm/llvm-project/pull/133461
More information about the llvm-commits
mailing list