Skip to content

Commit

Permalink
Merge remote-tracking branch 'remote-undef-static-init-branch-undef-s…
Browse files Browse the repository at this point in the history
…tatic-init/undef-static-init' into merge-head
  • Loading branch information
DiamondLovesYou committed Apr 19, 2020
2 parents 5d76dfa + 53d5562 commit 4890fe8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/librustc_codegen_llvm/consts.rs
Expand Up @@ -74,7 +74,18 @@ pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll
llvals.push(cx.const_bytes(bytes));
}

cx.const_struct(&llvals, true)
let out = cx.const_struct(&llvals, true);

if alloc.relocations().len() == 0 {
let umask = alloc.undef_mask();
if (0..alloc.len()).all(|i| !umask.get(Size::from_bytes(i)) ) {
// use a real undef value:
let ty = crate::common::val_ty(out);
return cx.const_undef(ty);
}
}

out
}

pub fn codegen_static_initializer(
Expand Down

0 comments on commit 4890fe8

Please sign in to comment.