[llvm] Revert "[SimplifyCFG] Deduce paths unreachable if they cause div/rem UB" (PR #137741)

Bill Wendling via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 29 03:04:38 PDT 2025


bwendling wrote:

> Not sure what exactly that error is supposed to tell us, but maybe the `-trap-unreachable -no-trap-after-noreturn` variant would work? That's the configuration that Rust uses by default. Enabling this for Clang as well comes up regularly as well (basically whenever a new person discovers function fallthrough), but nobody has bothered actually implementing it yet.

>From what Linus commented, it looks like Clang isn't honoring unreachable code, and will generate some instructions after it. In the specific case, the `panic()` call, which is marked "noreturn".

Both of those flags were suggested to Linus, and they work in my tree. The problem is that Linux tests their binary files much more thoroughly than many programmers do. The use of these hidden flags won't be known to the majority of people, nor will they know if they need them.

I'm very fine with further discussion on how best to handle a subset of UBs, but I'd like to revert this patch first. We could then have a discussion on whether or not adding a `__builtin_trap()` to avoid accidental fallthroughs from one function to another is a Good Thing(tm).

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


More information about the llvm-commits mailing list