[LLVMdev] How to not zeroinitialize array

Russell Hadley rhadley at microsoft.com
Tue Jul 21 14:54:11 PDT 2015


Thanks the .bss trick was part of it.  I had another wire crossed but I've got it straightened now.

-----Original Message-----
From: Tim Northover [mailto:t.p.northover at gmail.com] 
Sent: Tuesday, July 21, 2015 1:46 PM
To: Russell Hadley
Cc: llvmdev at cs.uiuc.edu
Subject: Re: [LLVMdev] How to not zeroinitialize array

Hi Russel,

On 21 July 2015 at 13:31, Russell Hadley <rhadley at microsoft.com> wrote:
> My question is where is this transform happening – it looks like it’s 
> a byproduct of parsing the ll file which was super surprising to me.

It's not even a transformation. It's just a shorthand used for printing out (and reading in) a constant 0. What you want to do (well, what you think you want to do) is prevent LLVM from putting any 0 data in a special section when compiling.

> And second is there a know what to circumvent this?  For my app I just 
> want the zero’d space in the section so I can copy it into memory.

This is probably better handled at the linker level, but for hacking purposes there does seem to be an llc option to override the choice to use automatic zero-fill: -nozero-initialized-in-bss. I've never used it, but it may help for some quick tests.

Cheers.

Tim.




More information about the llvm-dev mailing list