[llvm-dev] Getting a pointer to a i8 from a global variable that holds a constant string

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Sat Apr 8 17:32:06 PDT 2017

Hi Lorin,

On 8 April 2017 at 05:18, Lorin Atzberger via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> return llvm::ConstantExpr::getGetElementPtr(nullptr,c,
> const_ptr_14_indices);

You need to be using the GlobalVariable as the base of the GEP, not
the ConstantDataArray. Then since it's been initialized to the string
you want, your GEP will pick up the first element of that string. The
ConstantDataArray isn't a pointer (it's an [N x i8], notionally in



More information about the llvm-dev mailing list