-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustc puts zero-initalized structs in .data instead of .bss if they contain padding #41315
Comments
Looking at LLVM IR: @_ZN1t12DMA_RECORDER17h7409bdfe01c28df8E =
internal global { i1, [8388608 x i8], [7 x i8], i64 }
{ i1 false, [8388608 x i8] zeroinitializer, [7 x i8] undef, i64 0 }, align 8 It looks like that the padding |
bool
fields
So I'm not sure what to do here. This is clearly also an LLVM issue, but with LLVM being supported down to 3.7, fixing just LLVM doesn't seem enough. |
If it's indeed an LLVM bug, fixing LLVM and cherry-picking the patch into https://github.com/rust-lang/llvm/ may be the best we can do. This is often the case with LLVM issues, even with blatant miscompiles (e.g., #40593). |
I tagged this as |
Relevant thread on llvm-dev: http://lists.llvm.org/pipermail/llvm-dev/2017-April/112305.html (well, not a thread just yet) |
Still reproduces on 1.20 and |
I have a patch for this here. It's been accepted, so now it just needs to be merged and then we should be able to cherry-pick it. |
Following up on the discussion from http://lists.llvm.org/pipermail/llvm-dev/2017-April/112305.html, undef values are now placed in the .bss as well as null values. This prevents undef global values taking up potentially huge amounts of space in the .data section. The following two lines now both generate equivalent .bss data: @vals1 = internal unnamed_addr global [20000000 x i32] zeroinitializer, align 4 @Vals2 = internal unnamed_addr global [20000000 x i32] undef, align 4 ; previously unaccounted for This is primarily motivated by the corresponding issue in the Rust compiler (rust-lang/rust#41315). Differential Revision: https://reviews.llvm.org/D41705 Patch by varkor! llvm-svn=324424
Following up on the discussion from http://lists.llvm.org/pipermail/llvm-dev/2017-April/112305.html, undef values are now placed in the .bss as well as null values. This prevents undef global values taking up potentially huge amounts of space in the .data section. The following two lines now both generate equivalent .bss data: @vals1 = internal unnamed_addr global [20000000 x i32] zeroinitializer, align 4 @Vals2 = internal unnamed_addr global [20000000 x i32] undef, align 4 ; previously unaccounted for This is primarily motivated by the corresponding issue in the Rust compiler (rust-lang/rust#41315). Differential Revision: https://reviews.llvm.org/D41705 Patch by varkor! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@324424 91177308-0d34-0410-b5e6-96231b3b80d8
This has now been merged in. Should be ready for cherry-picking! |
Yay! Thanks @varkor! If someone wants to drive this to the finish line the backporting process looks like this:
Feel free to cc me on those PRs. I can only r+ the rust-lang/rust PR, though. |
Following up on the discussion from http://lists.llvm.org/pipermail/llvm-dev/2017-April/112305.html, undef values are now placed in the .bss as well as null values. This prevents undef global values taking up potentially huge amounts of space in the .data section. The following two lines now both generate equivalent .bss data: @vals1 = internal unnamed_addr global [20000000 x i32] zeroinitializer, align 4 @Vals2 = internal unnamed_addr global [20000000 x i32] undef, align 4 ; previously unaccounted for This is primarily motivated by the corresponding issue in the Rust compiler (rust-lang/rust#41315). Differential Revision: https://reviews.llvm.org/D41705 Patch by varkor! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@324424 91177308-0d34-0410-b5e6-96231b3b80d8
@japaric: thanks for laying out the steps! I always meant to follow up here, but never got around to it (and wasn't sure what the process was on the rust/llvm end). I've followed the first steps: hopefully we can soon get this fix in for good! :) |
Following up on the discussion from http://lists.llvm.org/pipermail/llvm-dev/2017-April/112305.html, undef values are now placed in the .bss as well as null values. This prevents undef global values taking up potentially huge amounts of space in the .data section. The following two lines now both generate equivalent .bss data: @vals1 = internal unnamed_addr global [20000000 x i32] zeroinitializer, align 4 @Vals2 = internal unnamed_addr global [20000000 x i32] undef, align 4 ; previously unaccounted for This is primarily motivated by the corresponding issue in the Rust compiler (rust-lang/rust#41315). Differential Revision: https://reviews.llvm.org/D41705 Patch by varkor! llvm-svn: 324424
E.g.:
(and this results in a 8MB file, etc).
Note that this works:
The text was updated successfully, but these errors were encountered: