[LLVMdev] Having trouble with GEP

Dirkjan Ochtman dirkjan at ochtman.nl
Tue Jan 15 13:30:26 PST 2013


I'm running up against an error with this IR:

%array$str = type { i64, [0 x %str] }
%array.raw = call i8* @malloc(i64 %objsz)
%array = bitcast i8* %array.raw to %array$str*
%array.data = getelementptr %array$str* %array, i32 0, i32 1

This is kind of hand-written, but it errors out, like this:

print-var.ll:50:30: error: invalid getelementptr indices
        %array.data = getelementptr %array$str* %array, i32 0, i32 1
                                    ^
1 error generated.

I can't figure out what the problem is here. I asked in IRC, but I
haven't gotten any useful answers; some people were surprised about
the unquoted use of $ in the type name, but in my testing, that seems
to be fine (as it should be, according to the LangRef).

A hint would be much appreciated, cheers,

Dirkjan



More information about the llvm-dev mailing list