Skip to content

[MIR] Unecessary code for some ZST stores are generated #30831

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

Closed
nagisa opened this issue Jan 11, 2016 · 0 comments
Closed

[MIR] Unecessary code for some ZST stores are generated #30831

nagisa opened this issue Jan 11, 2016 · 0 comments

Comments

@nagisa
Copy link
Member

nagisa commented Jan 11, 2016

Code like the following one

use std::marker::PhantomData;

struct Zst { phantom: PhantomData<Zst> }

#[rustc_mir(graphviz="foo.gv")]
fn mir(){
    let x = Zst { phantom: PhantomData };
}

generates some unnecessary LLVM IR. Namely:

bb0:                                              ; preds = %entry-block
  %0 = getelementptr inbounds %Zst, %Zst* %x, i32 0, i32 0
  store %"2.core::marker::PhantomData<Zst>" undef, %"2.core::marker::PhantomData<Zst>"* %0, align 1
  br label %bb1

We should skip zero-sized fields in this code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant