[llvm] [BOLT] Simplify RAState helpers (NFCI) (PR #162820)
Peter Waller via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 28 04:49:25 PDT 2025
================
@@ -81,10 +86,15 @@ void InsertNegateRAState::coverFunctionFragmentStart(BinaryFunction &BF,
});
// If a function is already split in the input, the first FF can also start
// with Signed state. This covers that scenario as well.
- if (BC.MIB->isRASigned(*((*FirstNonEmpty)->begin()))) {
+ auto RAState = BC.MIB->getRAState(*(*FirstNonEmpty)->begin());
+ if (!RAState) {
+ BC.errs() << "BOLT-ERROR: unknown RAState after inferUnknownStates "
+ << " in function " << BF.getPrintName() << "\n";
+ return;
----------------
peterwaller-arm wrote:
>From https://llvm.org/docs/CodingStandards.html:
> The ``llvm_unreachable`` function can be used to document areas of control flow
> that should never be entered if the program invariants hold:
>
> .. code-block:: c++
>
> enum { Foo, Bar, Baz } X = foo();
>
> switch (X) {
> case Foo: /* Handle Foo */; break;
> case Bar: /* Handle Bar */; break;
> default:
> llvm_unreachable("X should be Foo or Bar here");
> }
>
> Additionally, ``reportFatalInternalError`` can be used to report invariant
> violations even in builds that do not enable assertions:
>
> .. code-block:: c++
>
> if (VerifyFooAnalysis && !Foo.verify()) {
> reportFatalInternalError("Analysis 'foo' not preserved");
> }
The coding standards suggest llvm_unreachable may only be visible in assertions builds. If there is a risk this could happen in the real world, a fatal internal error would be preferable. Bolt doesn't use this function, the standard appears to be to simply exit if there is nothing more to be done.
https://github.com/llvm/llvm-project/pull/162820
More information about the llvm-commits
mailing list