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

MIR const-prop not putting usize into AggregateKind::RawPtr? #124792

Closed
scottmcm opened this issue May 6, 2024 · 2 comments · Fixed by #125041
Closed

MIR const-prop not putting usize into AggregateKind::RawPtr? #124792

scottmcm opened this issue May 6, 2024 · 2 comments · Fixed by #125041
Labels
A-mir-opt Area: MIR optimizations C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@scottmcm
Copy link
Member

scottmcm commented May 6, 2024

Discord Context: https://discord.com/channels/273534239310479360/273541522815713281/1236936970912137236

I was surprised in https://rust.godbolt.org/z/hnMT6K4qh to see

        _18 = const 128_usize;
        StorageLive(_24);
        _24 = _22 as *const () (PtrToPtr);
        _23 = *const [u8] from (_24, _18);

Because I would have expected constprop into the Aggregate, like

        StorageLive(_24);
        _24 = _22 as *const () (PtrToPtr);
        _23 = *const [u8] from (_24, const 128_usize);

As happened in other places, like

        _20 = Offset(_16, const 128_usize);
        StorageLive(_21);
        _21 = Sub(_13, const 128_usize);

AggregateKind::RawPtr is relatively new (#123840), so maybe it needs to be handled properly somewhere else?

@scottmcm scottmcm added the A-mir-opt Area: MIR optimizations label May 6, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 6, 2024
@saethlin saethlin added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 12, 2024
@saethlin
Copy link
Member

I think the problem is this FIXME that you added:

// FIXME: Do the extra work to GVN `from_raw_parts`
AggregateKind::RawPtr(..) => return None,

Constant propagation is done by GVN.

@scottmcm
Copy link
Member Author

Foiled once again by my greatest nemesis: my past self.

Thanks, @saethlin

@scottmcm scottmcm linked a pull request May 12, 2024 that will close this issue
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants