<div dir="ltr">Hi Wei,<div><br></div><div>You wrote:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><i>I try the following testcase using GCC and GCC still use 1024B stack</i></div></div></div><div><div><i>for it. So maybe GCC's implemention can still be improved?</i></div></div></blockquote><div><div><br></div></div><div>Yes, just so. What is happening here is that the code in GCC is looking at "x + 2" in the final BB and conservatively assuming that it could write memory. This means that conflicts are added between everything in the work set, hence no overlap.</div><div><br></div><div>On the other hand, the GCC stuff runs at all optimization levels (even -O0), so it makes sense that it is simple/conservative.</div><div><br></div><div>Than</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 11, 2016 at 2:10 PM, Wei Mi <span dir="ltr"><<a href="mailto:wmi@google.com" target="_blank">wmi@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Mon, Apr 11, 2016 at 10:38 AM, Than McIntosh <<a href="mailto:thanm@google.com">thanm@google.com</a>> wrote:<br>
><br>
> thanm added a comment.<br>
><br>
> Wei wrote: //But isn't bar() could potentially change ar1 and ar2 indirectly since ar1 and ar2 are escaped local arrays from current func?//<br>
><br>
> GCC's implementation completely ignores "lifetime start" and instead adds a var X to the work set the first time it sees a reference to it. So on entry to BB1 it has not yet seen any references to "ar2", so when it processes "call bar(&ar1)" no edge is added. Ditto for processing BB2; live-in for the block is empty (since no explicit references in the entry block), so when it sees "call bar(&a2)" no edge is added. Both ar1 and ar1 are part of the work set on entry to BB3, but BB3 has no instructions that could access memory.<br>
><br>
</span>Thanks.<br>
<br>
I try the following testcase using GCC and GCC still use 1024B stack<br>
for it. So maybe GCC's implemention can still be improved?<br>
<br>
extern void inita(int , int, const char *);<br>
<br>
int ifthen(int x, int i)<br>
{<br>
  int itar1[128];<br>
  int itar2[128];<br>
<br>
  if (x & 1) {<br>
    itar1[i] = 7;<br>
    inita(itar1[3], 128, "ifthen_itar1");<br>
  } else {<br>
    itar2[i] = 7;<br>
    inita(itar2[5], 128, "ifthen_itar2");<br>
  }<br>
  return x+2;<br>
}<br>
<br>
Thanks,<br>
Wei.<br>
</blockquote></div><br></div>