mirror of
https://github.com/apple/swift.git
synced 2026-11-24 07:03:51 +01:00
Also replace LLVM_BUILTIN_UNREACHABLE with LLVM_BUILTIN_TRAP in a few places where it's used directly. builtin_unreachable is undefined behavior when reached, which makes it a major hazard, as the optimizer will happly eliminate branches that lead to one. This can make for difficult debugging experiences or arbitrary bad behavior at runtime as we end up on "impossible" code paths when there's unexpected data. It works in cases where the code is provably unreachable, but in practice it often ends up in places where execution shouldn't reach but can due to bugs or unanticipated input. This change will have a small penalty to performance (due to checks that previously got optimized out) and code size (due to code paths that previously got optimized out). This should be negligible.