Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken MIR in encoding_rs related to MIR inlining + DestProp #105428

Closed
saethlin opened this issue Dec 7, 2022 · 1 comment · Fixed by #105420
Closed

Broken MIR in encoding_rs related to MIR inlining + DestProp #105428

saethlin opened this issue Dec 7, 2022 · 1 comment · Fixed by #105420
Labels
A-mir-opt Area: MIR optimizations C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way.

Comments

@saethlin
Copy link
Member

saethlin commented Dec 7, 2022

This was originally #105344 (comment)


Trying to compile https://github.com/hsivonen/encoding_rs 5931e21bc20bad0335964f441da0c4309401107a with these flags:

$ RUSTFLAGS="-Zmir-opt-level=3 -Zvalidate-mir -Zinline-mir=yes" cargo +nightly test

Produces this:

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:1315 ~ encoding_rs[5e1f]::utf_16::{impl#0}::decode_to_utf16_raw), const_param_did: None }) (before pass SimplifyCfg-final) at bb218[0]:
                                encountered overlapping memory in `Call` terminator: _454 = bswap::<u16>(move _454) -> bb163
  --> src/utf_16.rs:85:21
   |
85 |                     dest.copy_utf16_from::<LittleEndian>(&mut source)
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:784:26

Removing -Zinline-mir=yes or -Zmir-opt-level=3 removes the ICE.


searched nightlies: from nightly-2022-01-01 to nightly-2022-12-05
regressed nightly: nightly-2022-11-28
searched commit range: 80a9646...1eb62b1
regressed commit: 0e9eee6

bisected with cargo-bisect-rustc v0.6.5

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --script script --start 2022-01-01 --end 2022-12-05 
@RalfJung
Copy link
Member

RalfJung commented Jan 2, 2024

@tmiasko I am trying to understand what happened here. The test case added in #105420 looks like maybe the analysis done by DestProp is smart enough to ignore dead code and that's why it can introduce UB in dead code?

However the code at the top of this issue looks quite different. Looking at it's source, I can't see how ignoring dead code would lead to introducing overlapping calls?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants