<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">FYI: commited in <span style="color: rgba(0, 0, 0, 0.85098); font-family: 'Helvetica Neue';" class="">r279911 </span><div class=""><font color="rgba(0, 0, 0, 0.85098)" face="Helvetica Neue" class=""><br class=""></font></div><div class=""><font face="Helvetica Neue" class=""><font color="#000085" class="">—</font><font color="rgba(0, 0, 0, 0.85098)" class=""> </font></font></div><div class=""><font face="Helvetica Neue" class=""><font color="#000085" class="">Mehdi</font></font></div><div class=""><font face="Helvetica Neue" class=""><font color="#000085" class=""><br class=""></font></font><div class=""><font color="rgba(0, 0, 0, 0.85098)" face="Helvetica Neue" class=""><br class=""></font><div><blockquote type="cite" class=""><div class="">On Aug 26, 2016, at 5:34 PM, Teresa Johnson <<a href="mailto:tejohnson@google.com" class="">tejohnson@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I have a fix, just running tests.</div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Aug 26, 2016 at 4:03 PM, Teresa Johnson <span dir="ltr" class=""><<a href="mailto:tejohnson@google.com" target="_blank" class="">tejohnson@google.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote"><span class="">On Fri, Aug 26, 2016 at 3:07 PM, Mehdi Amini <span dir="ltr" class=""><<a href="mailto:mehdi.amini@apple.com" target="_blank" class="">mehdi.amini@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br class="">
> On Aug 26, 2016, at 2:06 PM, Teresa Johnson <<a href="mailto:tejohnson@google.com" target="_blank" class="">tejohnson@google.com</a>> wrote:<br class="">
><br class="">
> Mehdi: I see what is going on:<br class="">
><br class="">
> +    ArrayType *Ty =<br class="">
> +        ArrayType::get(Type::getInt8Ty<wbr class="">(RegularLTO.Ctx), I.second.Size);<br class="">
> +    GlobalVariable *OldGV = RegularLTO.CombinedModule->get<wbr class="">NamedGlobal(I.first);<br class="">
> +    if (OldGV && OldGV->getType()->getElementTy<wbr class="">pe() == Ty) {<br class="">
> +      // Don't create a new global if the type is already correct, just make<br class="">
> +      // sure the alignment is correct.<br class="">
><br class="">
> We compare the existing type to an ArrayType constructed from the<br class="">
> recorded merged common size. So<br class="">
> the original i32 type does not look the same (since it compares<br class="">
> against [4 x i8]).<br class="">
<br class="">
</span>Right, but that the code I wrote in r279417 right? I guess we should compare the *size* first, and only do something if the size differs.<br class=""></blockquote><div class=""><br class=""></div></span><div class="">Yeah. In fact the original handling added in r278338 (addCommons) didn't even compare the size, it always created a new merged common with an ArrayType.</div><span class=""><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="">
How was Gold doing it before r278338?<br class=""></blockquote><div class=""><br class=""></div></span><div class="">It was just letting the ModuleLinker handle it (which kept the largest one by size), and then it fixed up the alignment later.</div><div class=""><br class=""></div><div class="">Will change to first compare the size.</div><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="">
—<div class=""><div class="h5"><br class="">
<span class="m_1134758001181772588HOEnZb"><font color="#888888" class="">Mehdi<br class="">
</font></span><div class="m_1134758001181772588HOEnZb"><div class="m_1134758001181772588h5"><br class="">
<br class="">
<br class="">
<br class="">
><br class="">
> Not that familiar with type handling in LLVM, but I guess I need to<br class="">
> just check if the type size is the same?<br class="">
><br class="">
> On Fri, Aug 26, 2016 at 1:57 PM, Teresa Johnson <<a href="mailto:tejohnson@google.com" target="_blank" class="">tejohnson@google.com</a>> wrote:<br class="">
>> Thanks for the test case! I can reproduce this, and see with the<br class="">
>> compiler I saved from just before r278338 that this is indeed a chance<br class="">
>> in behavior. Looking at why this changed...<br class="">
>><br class="">
>> On Fri, Aug 26, 2016 at 1:42 PM, Mehdi Amini <<a href="mailto:mehdi.amini@apple.com" target="_blank" class="">mehdi.amini@apple.com</a>> wrote:<br class="">
>>><br class="">
>>>> On Aug 26, 2016, at 1:34 PM, <a href="mailto:junbuml@codeaurora.org" target="_blank" class="">junbuml@codeaurora.org</a> wrote:<br class="">
>>>><br class="">
>>>> On 2016-08-26 12:47, Mehdi Amini wrote:<br class="">
>>>>>> On Aug 26, 2016, at 9:06 AM, <a href="mailto:junbuml@codeaurora.org" target="_blank" class="">junbuml@codeaurora.org</a> wrote:<br class="">
>>>>>> On 2016-08-26 11:32, Mehdi Amini wrote:<br class="">
>>>>>>> Hi,<br class="">
>>>>>>>> Recently, I noticed that less number of global variables are merged in global-merge pass and in some global variable, array types are used instead of its original type. For example, [4xi8] with align 4 is used for a i32  global variable. For me, it seems that such pattern is observed after r278338  (Resolution-based LTO API).<br class="">
>>>>>>> Are you sure it is performed in the global merge pass? Can you provide<br class="">
>>>>>>> an example of input IR where you see this now but didn’t before?<br class="">
>>>>>>> Also can you confirm you’re using the gold-linker?<br class="">
>>>>>> I used gold linker. In spec2006/perlbench, I observed the less number of globals are merged in GlobalMerge.cpp after r278338. The reason is because, from the very first pass, several global variables use [4xi8] with align 4, instead of its original type i32 after r278338. Current GlobalMerge pass doesn't seem to handle such fancy-aligned globals. If such type change (e.g., from i32 to [4xi8]) in global variables was intended in r278338, I think we should enhance GlobalMerge to handle such cases.<br class="">
>>>>> Can you submit a reproduction for Gold please?<br class="">
>>>>> We need to understand what changed with the new LTO API.<br class="">
>>>><br class="">
>>>><br class="">
>>>> I compiled below C code for aarch64 in lto using gold (--target=aarch64-linux-gnu  -flto -fuse-ld=gold). After r278338, two globals, GVi32_a and GVi32_b, are [4 x i8] type in the input IR to GlobalMerge. Therefore, GlobalMerge do not even start to handle them because as of now it ignores fancy-aligned globals.  Before r278338, GVi32_a and GVi32_b seems to be i32 in the input IR to GlobalMerge. Is this change in the input IR expected ?<br class="">
>>>><br class="">
>>>> -------------------------<br class="">
>>>> int GVi32_a  ;<br class="">
>>>> int GVi32_b  ;<br class="">
>>><br class="">
>>> These are common variables, this is what I mentioned in my first email. Compiling with -fno-commons or defining them with “int GVi32_a = 0;” should solve it.<br class="">
>>><br class="">
>>> However r278338 is not supposed to have changed anything on this aspect. I would have expected maybe r279417 playing a role there.<br class="">
>>><br class="">
>>> Anyway I don’t have Gold, so I’ll leave Teresa investigate why the change in behavior.<br class="">
>>><br class="">
>>> Do you want to try improving global merge to try to handle this case?<br class="">
>>><br class="">
>>> —<br class="">
>>> Mehdi<br class="">
>>><br class="">
>>><br class="">
>>><br class="">
>>><br class="">
>>><br class="">
>>>><br class="">
>>>> __attribute__((noinline)) void setGV(int a) {<br class="">
>>>> GVi32_a = a ;<br class="">
>>>> GVi32_b = a ;<br class="">
>>>> }<br class="">
>>>><br class="">
>>>> __attribute__((noinline)) int loadGV() {<br class="">
>>>> return GVi32_a + GVi32_b  ;<br class="">
>>>> }<br class="">
>>>><br class="">
>>>> int main(int argc, char *argv[]){<br class="">
>>>> setGV(argc);<br class="">
>>>> return loadGV();<br class="">
>>>> }<br class="">
>>>> -------------------------<br class="">
>>>><br class="">
>>>><br class="">
>>>><br class="">
>>>>> —<br class="">
>>>>> Mehdi<br class="">
>>>><br class="">
>>>> --<br class="">
>>>> Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.<br class="">
>>>> Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.<br class="">
>>><br class="">
>><br class="">
>><br class="">
>><br class="">
>> --<br class="">
>> Teresa Johnson | Software Engineer | <a href="mailto:tejohnson@google.com" target="_blank" class="">tejohnson@google.com</a> | <a href="tel:408-460-2413" value="+14084602413" target="_blank" class="">408-460-2413</a><br class="">
><br class="">
><br class="">
><br class="">
> --<br class="">
> Teresa Johnson | Software Engineer | <a href="mailto:tejohnson@google.com" target="_blank" class="">tejohnson@google.com</a> | <a href="tel:408-460-2413" value="+14084602413" target="_blank" class="">408-460-2413</a><br class="">
<br class="">
</div></div></div></div></blockquote></div><div class=""><div class="h5"><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="m_1134758001181772588gmail_signature" data-smartmail="gmail_signature"><span style="font-family: Times; font-size: inherit;" class=""><table cellspacing="0" cellpadding="0" class=""><tbody class=""><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small" class=""><td nowrap="" style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px" class="">Teresa Johnson |</td><td nowrap="" style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px" class=""> Software Engineer |</td><td nowrap="" style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px" class=""> <a href="mailto:tejohnson@google.com" target="_blank" class="">tejohnson@google.com</a> |</td><td nowrap="" style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px" class=""> <a href="tel:408-460-2413" value="+14084602413" target="_blank" class="">408-460-2413</a></td></tr></tbody></table></span></div>
</div></div></div></div>
</blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature" data-smartmail="gmail_signature"><span style="font-family: Times; font-size: inherit;" class=""><table cellspacing="0" cellpadding="0" class=""><tbody class=""><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small" class=""><td nowrap="" style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px" class="">Teresa Johnson |</td><td nowrap="" style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px" class=""> Software Engineer |</td><td nowrap="" style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px" class=""> <a href="mailto:tejohnson@google.com" target="_blank" class="">tejohnson@google.com</a> |</td><td nowrap="" style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px" class=""> 408-460-2413</td></tr></tbody></table></span></div>
</div>
</div></blockquote></div><br class=""></div></div></body></html>