[LLVMdev] Confusion between GetElementPtr and C++ API

charles quarra charllsnotieneningunputocorreo at gmail.com
Sun Apr 12 18:19:32 PDT 2015


Looking at the documentation of `GetElementPtr`:

http://llvm.org/docs/GetElementPtr.html


The examples rely on multiple indexes: the 1st for the struct member
and the 2nd for the element in the array. This supposedly returns an
offset from the base pointer

I'm trying to figure out what's the correct way to create a given
`GetElementPtr` instruction with the C++ API. Unfortunately, there are
several varieties of the `CreateXXXGEP` instruction, with a parameter
"val" that I presume is one of the indices. No version of it seems to
use two indices as in the documentation:
http://llvm.org/docs/doxygen/html/classllvm_1_1IRBuilder.html

Even the `CreateStructGEP` uses a single idx parameter!


I want to do a very simple thing; I want to take a char buffer:

    Value* vB = llvm::ConstantDataArray::GetString(...)

and use the pointer to the array to pass it to another function that
expects `i8*`



More information about the llvm-dev mailing list