[llvm-dev] Must string literals be declared as a global variable in LLVM IR?

Eli Friedman via llvm-dev llvm-dev at lists.llvm.org
Tue Jan 22 12:52:32 PST 2019

On 1/22/2019 12:48 PM, Peng Yu 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?

You can always write a sequence of byte stores to store each character. 
Of course, that's not very efficient for long strings.


Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

More information about the llvm-dev mailing list