With LLVM 2.7, I see very inefficient emitting of zeros in .s files: test_: # @test_ .quad 0 # 0x0 .quad 0 # 0x0 .quad 0 # 0x0 .quad 0 # 0x0 .quad 0 # 0x0 .quad 0 # 0x0 [...] .quad 4 # 0x4 .quad 4 # 0x4 .quad 4 # 0x4 .quad 4 # 0x4 [...] The [...] pieces are huge. This isn't a zeroinitializer so its not simply a matter of emitting zeroinitializers more efficiently. Ideally we'd emit the zeros with a .zero directive. In this case, doing so is the difference between a 3MB asm file and a 20MB asm file. I searched the bug database but didn't find anything about this. Has anyone looked at improving this? If not I'll work on it and get a patch sent up. But maybe it's fixed in 2.8 or something. -Dave
On Sep 16, 2010, at 5:12 PM, David Greene wrote:> With LLVM 2.7, I see very inefficient emitting of zeros in .s files: > > test_: # @test_ > .quad 0 # 0x0 > .quad 0 # 0x0 > .quad 0 # 0x0 > .quad 0 # 0x0 > .quad 0 # 0x0 > .quad 0 # 0x0 > [...] > .quad 4 # 0x4 > .quad 4 # 0x4 > .quad 4 # 0x4 > .quad 4 # 0x4 > [...] > > The [...] pieces are huge. This isn't a zeroinitializer so its not > simply a matter of emitting zeroinitializers more efficiently. > > Ideally we'd emit the zeros with a .zero directive. > > In this case, doing so is the difference between a 3MB asm file and a > 20MB asm file. > > I searched the bug database but didn't find anything about this. Has > anyone looked at improving this? If not I'll work on it and get a > patch sent up. > > But maybe it's fixed in 2.8 or something.It's not fixed in 2.8, it sounds like it's simple code in AsmPrinter when emitting a ConstantStruct or something. A simple testcase would be helpful. -Chris
Chris Lattner <clattner at apple.com> writes:> On Sep 16, 2010, at 5:12 PM, David Greene wrote: > >> With LLVM 2.7, I see very inefficient emitting of zeros in .s files:>> But maybe it's fixed in 2.8 or something. > > It's not fixed in 2.8, it sounds like it's simple code in AsmPrinter > when emitting a ConstantStruct or something. A simple testcase would > be helpful.I have some 2.7 code to fix this now. Pretty easy fix. As a bonus it will aggregate all integer values, not just zero, but I don't think MCAsmStreamer currently optimizes that. I'll upstream it ASAP along with a testcase. -Dave