I doubt it, since Swift has a high level IR above LLVM IR and the
implementation isn't open-source. The language-specific optimizations
like removing overflow / bounds checks based on type system rules will
almost certainly be done on the high-level SIL IR, not at the LLVM IR
layer where most of the information is already lost.

No, the overflow checks in Swift will turn into LLVM intrinsics such as llvm.sadd.with.overflow. This is also what Rust would use. Then, the IR-level optimizations will try to remove these. LLVM already has a not-great integer range analysis that could be beefed up significantly without a whole lot of trouble.

Of course there's nothing stopping higher-level analyses from also attempting to avoid unnecessary overflow checks but I doubt that much or any of this is being done.

Rust 1.0 will be released in about 6 months, and these improvements
aren't going to happen in that time. It's a language for the present,
not one written for a fantasy architecture / compiler backend in 2025.

I wasn't arguing that Rust 1.0 should trap on integer overflow, I was arguing that the overhead of overflow checking isn't as high as you say. But I'd be happy to look at real data.

John
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to