<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 1, 2016 at 8:29 AM, Qin Zhao <span dir="ltr"><<a href="mailto:zhaoqin@google.com" target="_blank">zhaoqin@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">zhaoqin marked an inline comment as done.<br>
<span class=""><br>
================<br>
Comment at: lib/Transforms/Instrumentation/EfficiencySanitizer.cpp:738<br>
@@ +737,3 @@<br>
+        continue;<br>
+      CounterIdx = Idx->getZExtValue();<br>
+      if (CounterIdx >= StructTy->getNumElements())<br>
----------------<br>
</span><span class="">dberlin wrote:<br>
> So it looks like you just ignore any negative indices?<br>
> (but you don't mark them ignored)<br>
><br>
> Note that both<br>
>    %a = getelementptr inbounds {[2 x i8], [2 x i8]}, {[2 x i8], [2 x i8]}* %p, i32 0, i32 0, i32 1<br>
>   %b = getelementptr inbounds {[2 x i8], [2 x i8]}, {[2 x i8], [2 x i8]}* %p, i32 0, i32 1, i32 -1<br>
><br>
> are valid :)<br>
><br></span></blockquote><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class="">
</span>As you can see, the Idx here is to get from a struct field, if (isa<StructType>(Ty))<br></blockquote><div><br></div><div>The above is a struct.</div><div><br>It's</div><div>struct {<br>char a[2];</div><div>char b[2];</div><div>}</div><div><br></div><div>(</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
I do not think a negative index for struct field indexing is valid.<br></blockquote><div><br></div><div>You are incorrect :)<br>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"<br></div><br></div><div class="gmail_quote"><br></div><div class="gmail_quote">Clang will, AFAIK, generate negative GEP indexing for a bunch of things.</div><div class="gmail_quote"><br></div></div></div>