From 59850d0874429601812bc13408cb1f776649027c Mon Sep 17 00:00:00 2001
From: Roman Divacky This document seeks to dispel the mystery and confusion surrounding LLVM's
GetElementPtr (GEP) instruction. Questions about the wiley GEP instruction are
- probably the most frequently occuring questions once a developer gets down to
+ probably the most frequently occurring questions once a developer gets down to
coding with LLVM. Here we lay out the sources of confusion and show that the
GEP instruction is really quite simple.
In this example, idx1 computes the address of the second integer
- in the array that is in the structure in %MyVar, that is MyVar+4. The
- type of idx1 is i32*. However, idx2 computes the
- address of the next structure after %MyVar. The type of
- idx2 is { [10 x i32] }* and its value is equivalent
- to MyVar + 40 because it indexes past the ten 4-byte integers
- in MyVar. Obviously, in such a situation, the pointers don't
- alias.