[PATCH] D21594: [esan|cfrag] Add counters for struct array accesses

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 1 08:52:29 PDT 2016


>
>
> I do not think a negative index for struct field indexing is valid.
>>
>
> You are incorrect :)
>

FWIW, this is a common mistake.
Please remember that LLVM level structs and GEP do not have the same rules
and pretty much no relation to C-level structs.

GEP is just an indexing operation. Unlike C, i can form pointers to
wherever i want, and even if i mark them inbounds, your only guarantee is
that they are in the object somewhere, you have no guarantee on whether i
use positive or negative gep indices to generate those pointers and either
way is just as valid.
As mentioned, there are plenty of cases frontends will generate negative
gep indices for normal source level field accesses of C-level structs.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160701/958a9fda/attachment.html>


More information about the llvm-commits mailing list