[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:35:46 PDT 2016


On Fri, Jul 1, 2016 at 8:29 AM, Qin Zhao <zhaoqin at google.com> wrote:

> zhaoqin marked an inline comment as done.
>
> ================
> Comment at: lib/Transforms/Instrumentation/EfficiencySanitizer.cpp:738
> @@ +737,3 @@
> +        continue;
> +      CounterIdx = Idx->getZExtValue();
> +      if (CounterIdx >= StructTy->getNumElements())
> ----------------
> dberlin wrote:
> > So it looks like you just ignore any negative indices?
> > (but you don't mark them ignored)
> >
> > Note that both
> >    %a = getelementptr inbounds {[2 x i8], [2 x i8]}, {[2 x i8], [2 x
> i8]}* %p, i32 0, i32 0, i32 1
> >   %b = getelementptr inbounds {[2 x i8], [2 x i8]}, {[2 x i8], [2 x
> i8]}* %p, i32 0, i32 1, i32 -1
> >
> > are valid :)
> >
>


> As you can see, the Idx here is to get from a struct field, if
> (isa<StructType>(Ty))
>

The above is a struct.

It's
struct {
char a[2];
char b[2];
}

(

> I do not think a negative index for struct field indexing is valid.
>

You are incorrect :)
It has been discussed many times in the mailing list. The most recent is
"Claim NoAlias if two GEPs index different fields of the same struct"


Clang will, AFAIK, generate negative GEP indexing for a bunch of things.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160701/322141c0/attachment.html>


More information about the llvm-commits mailing list