[llvm-dev] Must string literals be declared as a global variable in LLVM IR?
Tim Northover via llvm-dev
llvm-dev at lists.llvm.org
Tue Jan 22 13:13:30 PST 2019
On Tue, 22 Jan 2019 at 20:48, Peng Yu via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> > If you want a pointer to a value, it has to be located somewhere in
> > memory. There are basically three places memory can be allocated in a
> > program: on the stack (alloca),
> Even I can alloca a chuck of memory, there is not a way to put the
> string constant to it? Sounds likely there is not way to avoid the
> initialization of the global variables. Is it?
Globals, especially ones as simple as strings, tend to be
"initialized" just by being mapped into memory by the kernel from the
executable file. It's the best possible initialization (no
computation, no explicit instructions, it's all just an mmap); all the
global variable is doing is giving you a handle to this string that
you've requested should be available.
More information about the llvm-dev