[llvm] [BOLT][AArch64] Handle OpNegateRAState to enable optimizing binaries with pac-ret hardening (PR #120064)
Paschalis Mpeis via llvm-commits
llvm-commits at lists.llvm.org
Tue May 6 11:49:56 PDT 2025
================
@@ -2769,10 +2770,12 @@ struct CFISnapshot {
llvm_unreachable("unsupported CFI opcode");
break;
case MCCFIInstruction::OpNegateRAState:
- if (!(opts::BinaryAnalysisMode || opts::HeatmapMode)) {
- llvm_unreachable("BOLT-ERROR: binaries using pac-ret hardening (e.g. "
- "as produced by '-mbranch-protection=pac-ret') are "
- "currently not supported by BOLT.");
+ if (!(opts::BinaryAnalysisMode || opts::HeatmapMode ||
+ opts::AllowPacret)) {
+ llvm_unreachable(
+ "BOLT-ERROR: support for binaries using pac-ret hardening (e.g. as "
+ "produced by '-mbranch-protection=pac-ret') is experimental\n"
+ "BOLT-ERROR: set --allow-experimental-pacret to allow processing");
----------------
paschalis-mpeis wrote:
This handling is repeated 3 places. Maybe it's worth to be added as a static function.
Also, although the new AllowPacret flag was introduced, both tests seem to pass without it.
The expected behavior would have been for both to fail, so maybe something is missing here?
Once fixed, you could adjust your lit tests to cover both paths, ie:
- `negate-ra-state.s` has:
- a CHECK that llvm-bolt fails when the allow-flag is not specified
- and succeeds+proceeds as normal when specifying the flag
- `negate-ra-state-incorrect.s` specifies the allow-flag and it succeeds
https://github.com/llvm/llvm-project/pull/120064
More information about the llvm-commits
mailing list