[llvm] [BOLT] Gadget scanner: analyze functions without CFG information (PR #133461)
Kristof Beyls via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 7 05:32:35 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) {
+ const MCInstrDesc &Desc = BC.MII->get(Inst.getOpcode());
+ // Adapted from llvm::MCInstrDesc::isUnconditionalBranch().
+ return Desc.isBranch() && Desc.isBarrier();
----------------
kbeyls wrote:
I wonder if what you're really after here is only checking for `Desc.isBarrier()`, because the documentation for `isBarrier` says:
```
/// Returns true if the specified instruction stops control flow
/// from executing the instruction immediately following it. Examples include
/// unconditional branches and return instructions.
```
Another example I encountered in real-world binaries for AArch64 is the `brk` instruction...
https://github.com/llvm/llvm-project/pull/133461
More information about the llvm-commits
mailing list