[LLVMdev] Pointers in Load and Store

Surinder surifilms at gmail.com
Thu Jan 20 20:02:09 PST 2011


When I compile C programs into llvm, it produces load instructions in
two different flavours.

(1)    %8 = load i8** %bp, align 8

(2)    %1 = load i8* getelementptr inbounds ([4 x i8]* @.str, i64 0,
i64 0), align 1

I know that %bp in first case and the entire "getelementptr inbounds
([4 x i8]* @.str, i64 0, i64 0)" in second case can be obtained by
dump'ing I.getOperand(0)

However, I want to find out which of the two forms of load have been
produced because in the second case, I want to insert checks for array
bounds.

How can I find out when I am in Instruction object I and I.getOpcode()
== 29 whether I am dealing with type (1) or type (2) above.

Thanks.

Surinder Kumar Jain



More information about the llvm-dev mailing list