[llvm] [AArch64][PAC] Simplify emission of authenticated pointer check (NFC) (PR #160899)

Anatoly Trosinenko via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 24 06:24:40 PST 2025


atrosinenko wrote:

Ping.

I updated the description to clarify the main idea: the `ShouldTrap` argument of the `emitPtrauthCheckAuthenticatedValue` can be computed from its other argument as `OnFailure == nullptr` at all the call sites. Out of the four existing call sites, the only one not passing constant `true, nullptr` arguments is that in the `emitPtrauthAuthResign` function:

```cpp
  // ...

  // Unchecked or checked-but-non-trapping AUT is just an "AUT": we're done.
  if (!IsAUTPAC && (!ShouldCheck || !ShouldTrap))
    return;

  MCSymbol *EndSym = nullptr;

  if (ShouldCheck) {
    if (IsAUTPAC && !ShouldTrap)
      EndSym = createTempSymbol("resign_end_");

    emitPtrauthCheckAuthenticatedValue(AUTVal, Scratch, AUTKey,
                                       AArch64PAuth::AuthCheckMethod::XPAC,
                                       ShouldTrap, EndSym);
  }

  // ...
```

If we got past the conditional return, `!IsAUTPAC && (!ShouldCheck || !ShouldTrap)` must evaluate to false, or in other words, `IsAUTPAC || (ShouldCheck && ShouldTrap)` must be true. Taking this into account, the contents of `if (ShouldCheck) { ... }` can be simplified to

```cpp
  if (ShouldCheck) {
    if (!ShouldTrap)
      EndSym = createTempSymbol("resign_end_");

    emitPtrauthCheckAuthenticatedValue(AUTVal, Scratch, AUTKey,
                                       AArch64PAuth::AuthCheckMethod::XPAC,
                                       ShouldTrap, EndSym);
  }
```

https://github.com/llvm/llvm-project/pull/160899


More information about the llvm-commits mailing list