Uh oh!
There was an error while loading. Please reload this page.
Use dangling for default slices (like vec and box do) - #62487
Conversation
More consistent and means LLVM doesn't need to faff about with useless private constants.
rust-highfive
commented
Jul 8, 2019
r? @aidanhs (rust_highfive has picked a reviewer for you, use r? to override) |
cramertj
commented
Jul 8, 2019
I frequently use |
I would be somewhat concerned if |
There is a slight codegen difference, but I wouldn't expect any perf difference from it. I just wanted this check to pass so my debugging printfs of std::ptr::eq(<&[u32]>::default(), <Vec<u32>>::default().as_slice()) |
totsteps
commented
Jul 23, 2019
ping from |
Second ping from |
hdhoang
commented
Aug 9, 2019
Third ping from triage, pinging reviewer in |
estebank
left a comment
There was a problem hiding this comment.
The code change looks reasonable but I share the concerns about codegen differences with &[]. I would prefer other reviewers in @rust-lang/compiler took a second look to verify we're not missing something obvious.
scottmcm
commented
Aug 9, 2019
Now that I'm back from vacation, I'd also be willing to take a look at changing something in mir transforms to generate the simpler version of this, if someone could point me to somewhere appropriate. (Presumably in the promotion code somewhere? Or maybe I could change |
eddyb
commented
Aug 9, 2019
@scottmcm You don't want to do this in MIR, but rather |
oli-obk
commented
Aug 9, 2019
Oh, I never thought about ZSTs when messing with llvm and constants. You should be able to just add an rust/src/librustc_codegen_llvm/common.rs Lines 299 to 304 in 4be0675 else branch.Though such a solution will miss |
nikomatsakis
commented
Aug 15, 2019
scottmcm
commented
Aug 17, 2019
Closing in favour of #63635 |
Do not generate allocations for zero sized allocations Alternative to rust-lang#62487 r? @eddyb There are other places where we could do this, too, but that would cause `static FOO: () = ();` to not have a unique address
More consistent and means LLVM & linking don't need to faff about with useless private constants.
(I suspect the previous way might also have meant it could return different things in different translation units, but I haven't actually checked whether that was happening.)