<div dir="auto">Is the size == 0 check going to work for all cases? I don't know how flexible array types are represented but if we have an int[1] in a global would this fail? Maybe have a check instead for: if constructor is not definitive and we are an array type then return false<div dir="auto"><br></div><div dir="auto">- Karl</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 29, 2020, 11:40 PM Doerfert, Johannes <<a href="mailto:jdoerfert@anl.gov">jdoerfert@anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I tried to track down more of the reasons behind the strict definitive<br>
initializer requirement because of other IPO/global opts we do.<br>
Unfortunately, I failed.<br>
<br>
It seems clear we cannot allow any global, as we cannot do IPO depending<br>
on the linkage. I suspect exact definitions are the least we need to<br>
make sure we don't get something entirely different at link time. Then<br>
there is the variable-length/empty size issue that seems to me as if it<br>
is a "on-off" special case.<br>
<br>
Based on the above assumptions I tried out what happens if we relax the<br>
condition, here is what I came up with: <a href="https://reviews.llvm.org/D73679" rel="noreferrer noreferrer" target="_blank">https://reviews.llvm.org/D73679</a><br>
<br>
<br>
On 01/29, Karl Rehm via llvm-dev wrote:<br>
> Interesting, so I guess we can check for whether it's an array type and<br>
> adjust accordingly instead? Blocking *all* global variables without<br>
> definitive initializers feels a bit much to me, especially if they have<br>
> primitive types (i.e. integers) that don't have the potential to be screwed<br>
> around with like this.<br>
> <br>
> On Wed, Jan 29, 2020 at 8:14 PM George Burgess IV <<br>
> <a href="mailto:george.burgess.iv@gmail.com" target="_blank" rel="noreferrer">george.burgess.iv@gmail.com</a>> wrote:<br>
> <br>
> > Looks like the commit that added that was<br>
> > <a href="https://github.com/llvm/llvm-project/commit/16e42128c24f5df8a61cfd2e6cdf3bd3966db0c5" rel="noreferrer noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/16e42128c24f5df8a61cfd2e6cdf3bd3966db0c5</a><br>
> > . A reduced example might look something like this:<br>
> > <a href="https://godbolt.org/z/r4G_g-" rel="noreferrer noreferrer" target="_blank">https://godbolt.org/z/r4G_g-</a><br>
> ><br>
> > At the C source level, static object size detection has to be similarly<br>
> > conservative in the face of 'variable-length' structs like `struct<br>
> > my_string { size_t size; char data[0]; };`, though I don't know how<br>
> > relevant that is here.<br>
> ><br>
> > On Tue, Jan 28, 2020 at 11:41 PM Karl Rehm via llvm-dev <<br>
> > <a href="mailto:llvm-dev@lists.llvm.org" target="_blank" rel="noreferrer">llvm-dev@lists.llvm.org</a>> wrote:<br>
> ><br>
> >> In this function (used to check the size of a global) there is an initial<br>
> >> check for whether the initializer to this function is "definitive." My<br>
> >> question is: why do we need this? How does the object's size change if a<br>
> >> global's initializer is defined at link time?<br>
> >><br>
> >> Thanks,<br>
> >> Karl<br>
> >> _______________________________________________<br>
> >> LLVM Developers mailing list<br>
> >> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank" rel="noreferrer">llvm-dev@lists.llvm.org</a><br>
> >> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
> >><br>
> ><br>
<br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank" rel="noreferrer">llvm-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br>
<br>
-- <br>
<br>
Johannes Doerfert<br>
Researcher<br>
<br>
Argonne National Laboratory<br>
Lemont, IL 60439, USA<br>
<br>
<a href="mailto:jdoerfert@anl.gov" target="_blank" rel="noreferrer">jdoerfert@anl.gov</a><br>
</blockquote></div>