make unit structs immediate

struct Foo;
    fn foo() -> Foo { Foo }

Before:

    ; Function Attrs: nounwind readnone uwtable
    define void @_ZN3foo18he8ca29755dedebbaf4v0.0E(%struct.Foo* noalias nocapture sret, { i64, %tydesc*, i8*, i8*, i8 }* nocapture) #0 {
    "function top level":
      ret void
    }

After:

    ; Function Attrs: nounwind readnone uwtable
    define %struct.Foo @_ZN3foo18he8ca29755dedebbaf4v0.0E({ i64, %tydesc*, i8*, i8*, i8 }* nocapture readnone) #0 {
    "function top level":
      ret %struct.Foo undef
    }
This commit is contained in:
Daniel Micay 2013-10-03 03:59:58 -04:00
parent ccd9a963f7
commit 249b356fb3

View File

@ -75,6 +75,9 @@ pub fn type_is_immediate(ccx: &mut CrateContext, ty: ty::t) -> bool {
}
match ty::get(ty).sty {
// FIXME: #9651: small `ty_struct` should also be immediate
ty::ty_struct(def_id, ref substs) => {
ty::struct_fields(tcx, def_id, substs).is_empty()
}
ty::ty_enum(*) | ty::ty_tup(*) => {
let llty = sizing_type_of(ccx, ty);
llsize_of_alloc(ccx, llty) <= llsize_of_alloc(ccx, ccx.int_type)