<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 29, 2016 at 3:40 PM, Taewook Oh <span dir="ltr"><<a href="mailto:twoh@fb.com" target="_blank">twoh@fb.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="m_2823919404413710213WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">It was r274523. I’m not sure it was the same module. By mistake I restarted the build with the previous version without backing backing up the build artifacts :(</span></p></div></div></blockquote><div><br></div><div>So a couple things were added to gold since then, index-based linkonce/weak resolution and some more aggressive internalization. I don't think either of these would have made the original problem go away, so I'm guessing that the latter provoked the new problem (in combination with pcc's earlier change to allow metadata attachments on decls that added that verifier assert). Presumably we started internalizing the promoted global, and something (presumably a later pass) then dropped the symbol. Let me see if I can provoke that particular issue with a debug ThinLTO build of SPEC (recently I have been testing non-debug). In the meantime, can you drop your debug flag and see if the first problem comes back?</div><div><br></div><div>Thanks,</div><div>Teresa</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="white" lang="EN-US" link="blue" vlink="purple"><div class="m_2823919404413710213WordSection1"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">Taewook<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><u></u> <u></u></span></p>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-family:Calibri;color:black">From: </span>
</b><span style="font-family:Calibri;color:black">Teresa Johnson <<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>><br>
<b>Date: </b>Friday, July 29, 2016 at 3:30 PM</span></p><div><div class="h5"><br>
<b>To: </b>Taewook Oh <<a href="mailto:twoh@fb.com" target="_blank">twoh@fb.com</a>><br>
<b>Cc: </b>via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject: </b>Re: [llvm-dev] [ThinLTO] assert(GS != DefinedGlobals.end()) failed in FunctionImport.cpp<u></u><u></u></div></div><p></p>
</div><div><div class="h5">
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Fri, Jul 29, 2016 at 2:25 PM, Taewook Oh <<a href="mailto:twoh@fb.com" target="_blank">twoh@fb.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">Hello Teresa,</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">Thank you for your analysis. One thing to note is that the global materializer materializes the value as a function declaration, not a function definition. As
I pasted on my first email, </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">; Materializable</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">; Function Attrs: nounwind uwtable</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">define weak_odr void @foo(%1*) unnamed_addr #7 comdat($comdat1) align 2 personality i32 (...)* @__gxx_personality_v0 {}</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">is materialized to
</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">; Function Attrs: nounwind uwtable</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">declare void @foo(%"type1"*) unnamed_addr #2 align 2</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">Inside IRLinker::linkGlobalValueProto, the materialized value is returned from getLinkedToGlobal(SGV) and assigned to DGV. However, as ForAlias is true and ShouldLink
is false, DGV becomes nullptr later, and NewGV is created from copyGlobalValueProto(SGV, ShouldLink) call. Therefore, returned value from linkGlobalValueProto is different from the value obtained by ValueMap.lookup(SGV) in IRLinker::materialize.</span><u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Ah, sorry, somehow I completely missed the fact that it was brought in as a decl when I looked this morning.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">BTW, I updated LLVM to the latest version in SVN this morning, and the assertion failure is gone. Instead, it ends up with broken module found errors:</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">Global is external, but doesn't have external or weak linkage!</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">void (%2*, %2*, i32)* @"_foo.llvm.E5F1952C"</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">function declaration may not have a !dbg attachment</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">void (%2*, %2*, i32)* @"_foo.llvm.E5F1952C"</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">LLVM ERROR: Broken module found, compilation aborted!</span><u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">This looks like a promoted local from the name. What is the linkage type? Is this the verifier run right after the importing pass?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I'm guessing the first problem went away due to luck, as I can't think of any specific change that would have affected it. Is this from the same module?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Do you know what SVN revision were you at before, even roughly?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Teresa<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">Hope this provides additional clues to fix the issue.
</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">Thanks,</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">Taewook</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri"> </span><u></u><u></u></p>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in;border-right-width:initial;border-bottom-width:initial;border-left-width:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial">
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><b><span style="font-family:Calibri;color:black">From:
</span></b><span style="font-family:Calibri;color:black">Teresa Johnson <<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>><br>
<b>Date: </b>Friday, July 29, 2016 at 7:05 AM</span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><br>
<b>To: </b>Taewook Oh <<a href="mailto:twoh@fb.com" target="_blank">twoh@fb.com</a>><br>
<b>Cc: </b>via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject: </b>Re: [llvm-dev] [ThinLTO] assert(GS != DefinedGlobals.end()) failed in FunctionImport.cpp<u></u><u></u></p>
</div>
</div>
</div>
<div>
<div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"> <u></u><u></u></p>
</div>
<div>
<div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"> <u></u><u></u></p>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"> <u></u><u></u></p>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal">On Thu, Jul 28, 2016 at 5:18 PM, Taewook Oh <<a href="mailto:twoh@fb.com" target="_blank">twoh@fb.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt;border-top-width:initial;border-right-width:initial;border-bottom-width:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial">
<div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">Hello Teresa,</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">Thank you for your reply. I’m trying to create a small repro but find it hard to nail down because originally it is a big build. This
happens with gold linker.</span><u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"> <u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal">I think I need to see a smaller test case, looking through the code I'm not sure how we ended up in this situation. See analysis below.<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt;border-top-width:initial;border-right-width:initial;border-bottom-width:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial">
<div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">Thanks,</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri">Taewook</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"><span style="font-size:11.0pt;font-family:Calibri"> </span><u></u><u></u></p>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in;border-right-width:initial;border-bottom-width:initial;border-left-width:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial">
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"><b><span style="font-family:Calibri;color:black">From:
</span></b><span style="font-family:Calibri;color:black">Teresa Johnson <<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>><br>
<b>Date: </b>Thursday, July 28, 2016 at 5:08 PM<br>
<b>To: </b>Taewook Oh <<a href="mailto:twoh@fb.com" target="_blank">twoh@fb.com</a>><br>
<b>Cc: </b>via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject: </b>Re: [llvm-dev] [ThinLTO] assert(GS != DefinedGlobals.end()) failed in FunctionImport.cpp</span><u></u><u></u></p>
</div>
<div>
<div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"> <u></u><u></u></p>
</div>
<div>
<div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal">Hi Taewook,
<u></u><u></u></p>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"> <u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"> <u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"> <u></u><u></u></p>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal">On Thu, Jul 28, 2016 at 4:38 PM, Taewook Oh via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt;border-top-width:initial;border-right-width:initial;border-bottom-width:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial">
<div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">Encountered “assert(GS != DefinedGlobals.end())” failure while running ThinLTO. The assertion statement is in MustPreserveGV lambda function in llvm::thinLTOInternalizeModule (lib/Transforms/IPO/FunctionImport.cpp).</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">It seems that the assertion fails because it fails to recover the "original name" of the global value. ModuleSummaryIndex::getOriginalNameBeforePromote attempts to get the original name by stripping .llvm.{HASH}, but what I observe
is that ".1" is still appended to the expected original name. </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">Then where this extra ".1" comes from? It is appended when the global value is materialized. IRLinker::materialize function calls IRLinker::linkGlobalValueProto function, and inside that function if DGV is nullptr or ShouldLink
is true then IRLinker::copyGlobalValueProto function is called to create a global variable in the destination module that corresponds to SGV. I found that newly created global variable has the extra ".1" added to the name of the SGV.
</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">When this happens? I don't have a complete understanding but I observed that the same global value is materialized twice during the single invocation of IRLinker::run, once with GlobalValueMaterializer and once with LocalValueMaterializer.
First, the global value</span><u></u><u></u></p>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal">Looking at the IRLinker, it appears this second (local) copy should only be created if there was no copy already linked in from the same source module:<u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"> <u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal">In IRLinker::linkGlobalValueProto, we should find the DGV created by the GlobalValueMaterializer for the same SGV (first find it by name, then if ShouldLink==true, we should find it in ValueMap and return that
entry, or if ShouldLink==false, since ForAlias=true we should return null.<u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"> <u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal">Then when linkGlobalValueProto returns, in IRLinker::materialize there is specific handling for this case:<u></u><u></u></p>
</div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"> // When linking a global for an alias, it will always be linked. However we<br>
// need to check if it was not already scheduled to satify a reference from a<br>
// regular global value initializer. We know if it has been schedule if the<br>
// "New" GlobalValue that is mapped here for the alias is the same as the one<br>
// already mapped. If there is an entry in the ValueMap but the value is<br>
// different, it means that the value already had a definition in the<br>
// destination module (linkonce for instance), but we need a new definition<br>
// for the alias ("New" will be different.<br>
if (ForAlias && ValueMap.lookup(SGV) == New)<br>
return New; <u></u><u></u></p>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"> <u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"> <u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal">AFAICT the only way we should be creating a new local copy is if foo() already had a copy in the dest module. But when we call ThinLTO internalization we are doing so before any function importing. The gold-plugin
should have linked the module being compiled in the ThinLTO backend into an empty module from thinLTOBackendTask, so we should not already have a copy of foo() in the dest module.<u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"> <u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal">I must be missing something...in lieu of a smaller test case, can you trace through what happens when we call linkGlobalValueProto for the local materializer, and see why we don't find the copy of SGV already materialized
by the global materializer which should be in the ValueMap?<u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"> <u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal">Thanks,<u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal">Teresa<u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt;border-top-width:initial;border-right-width:initial;border-bottom-width:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial">
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal">Yes, the IRLinker will append an integer if it encounters a naming conflict. Normally this would happen in full LTO, but I guess is happening here since we are linking twice due to the
alias.<u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt;border-top-width:initial;border-right-width:initial;border-bottom-width:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial">
<div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">; Materializable</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">; Function Attrs: nounwind uwtable</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">define weak_odr void @foo(%1*) unnamed_addr #7 comdat($comdat1) align 2 personality i32 (...)* @__gxx_personality_v0 {}</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">(I renamed the function and comdat)</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">is materialized with GlobalValueMaterializer, (so the IRLinker::materialize function is called with ForAlias == false), and the materialized value is</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">; Function Attrs: nounwind uwtable</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">declare void @foo(%"type1"*) unnamed_addr #2 align 2</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">Then, later, the same value is materialized again with LocalValueMaterializer (so ForAlias == true for IRLinker::materialize), and the materialized value is</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">; Function Attrs: nounwind uwtable</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">define internal void @foo.1(%"type 0x7efb6ee89d80"*) unnamed_addr #2 comdat($comdat1) align 2 personality i32 (...)* @__gxx_personality_v0 !dbg !12345 {</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt"> // function definition</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">}</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">(here, “type 0x7efb6ee89d80” is not “type1” )</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">So for me it seems that we need a mechanism to retrieve the original name of the global value even when it is renamed during the materialization. I submitted the bug report as well (<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D28760-29&d=CwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=kOsLCgQzH7N8ptZ7diJD9g&m=XtlNH01OW0mwOi0no2wur-HO6RY5szj-dgWaIcCki-k&s=9pGLGnxeOI3J3lvx9-ayiZJUImAefSzcGGJN5xo9_Kc&e=" target="_blank">https://llvm.org/bugs/show_bug.cgi?id=28760)</a>.</span><u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"> <u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal">Interestingly, we are already trying to handle a similar case in that lambda (see the comment about weak values linked in as a local copy due to an alias). However, we weren't anticipating
the original weak value being linked in as well, which is causing the rename.<u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"> <u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal">Do you have a small reproducer? Is this with gold? I need to think about the best way to handle this case. One way of course is to conservatively return true if we can't find it in the
map, but I don't love that since we may miss other cases that need to be handled.<u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"> <u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal">Thanks,<u></u><u></u></p>
</div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal">Teresa<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt;border-top-width:initial;border-right-width:initial;border-bottom-width:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial">
<div>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">Thanks,</span><u></u><u></u></p>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-m1800117222592206986gmail-msonormal">
<span style="font-size:11.0pt">Taewook</span><u></u><u></u></p>
</div>
</div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal" style="margin-bottom:12.0pt">
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Ddev&d=CwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=kOsLCgQzH7N8ptZ7diJD9g&m=XtlNH01OW0mwOi0no2wur-HO6RY5szj-dgWaIcCki-k&s=eA2ODuBrwjiWfuW-_sPfCVr1H774iHS5j89ydb7KY2E&e=" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><u></u><u></u></p>
</blockquote>
</div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"><br>
<br clear="all">
<u></u><u></u></p>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"> <u></u><u></u></p>
</div>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal">-- <u></u>
<u></u></p>
<div>
<table class="m_2823919404413710213MsoNormalTable" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td nowrap style="border:none;border-top:solid #d50f25 1.5pt;padding:0in 0in 0in 0in;border-right-width:initial;border-bottom-width:initial;border-left-width:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial">
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"><span style="font-family:Helvetica;color:#555555">Teresa Johnson |</span><u></u><u></u></p>
</td>
<td nowrap style="border:none;border-top:solid #3369e8 1.5pt;padding:0in 0in 0in 0in;border-right-width:initial;border-bottom-width:initial;border-left-width:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial">
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"><span style="font-family:Helvetica;color:#555555"> Software Engineer |</span><u></u><u></u></p>
</td>
<td nowrap style="border:none;border-top:solid #009939 1.5pt;padding:0in 0in 0in 0in;border-right-width:initial;border-bottom-width:initial;border-left-width:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial">
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"><span style="font-family:Helvetica;color:#555555"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</span><u></u><u></u></p>
</td>
<td nowrap style="border:none;border-top:solid #eeb211 1.5pt;padding:0in 0in 0in 0in;border-right-width:initial;border-bottom-width:initial;border-left-width:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial">
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"><span style="font-family:Helvetica;color:#555555"> <a href="tel:408-460-2413" target="_blank">408-460-2413</a></span><u></u><u></u></p>
</td>
</tr>
</tbody>
</table>
<p class="m_2823919404413710213m7471924872012567099gmail-m-1862324745509867527gmail-msonormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><br>
<br clear="all">
<u></u><u></u></p>
<div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"> <u></u><u></u></p>
</div>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal">-- <u></u><u></u></p>
<div>
<table class="m_2823919404413710213MsoNormalTable" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td nowrap style="border:none;border-top:solid #d50f25 1.5pt;padding:0in 0in 0in 0in;border-right-width:initial;border-bottom-width:initial;border-left-width:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial">
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-family:Helvetica;color:#555555">Teresa Johnson |</span><u></u><u></u></p>
</td>
<td nowrap style="border:none;border-top:solid #3369e8 1.5pt;padding:0in 0in 0in 0in;border-right-width:initial;border-bottom-width:initial;border-left-width:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial">
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-family:Helvetica;color:#555555"> Software Engineer |</span><u></u><u></u></p>
</td>
<td nowrap style="border:none;border-top:solid #009939 1.5pt;padding:0in 0in 0in 0in;border-right-width:initial;border-bottom-width:initial;border-left-width:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial">
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-family:Helvetica;color:#555555"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</span><u></u><u></u></p>
</td>
<td nowrap style="border:none;border-top:solid #eeb211 1.5pt;padding:0in 0in 0in 0in;border-right-width:initial;border-bottom-width:initial;border-left-width:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial">
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"><span style="font-family:Helvetica;color:#555555"> <a href="tel:408-460-2413" target="_blank">408-460-2413</a></span><u></u><u></u></p>
</td>
</tr>
</tbody>
</table>
<p class="m_2823919404413710213m7471924872012567099gmail-msonormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<table class="m_2823919404413710213MsoNormalTable" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td nowrap style="border:none;border-top:solid #d50f25 1.5pt;padding:0in 0in 0in 0in">
<p class="MsoNormal"><span style="font-family:Helvetica;color:#555555">Teresa Johnson |<u></u><u></u></span></p>
</td>
<td nowrap style="border:none;border-top:solid #3369e8 1.5pt;padding:0in 0in 0in 0in">
<p class="MsoNormal"><span style="font-family:Helvetica;color:#555555"> Software Engineer |<u></u><u></u></span></p>
</td>
<td nowrap style="border:none;border-top:solid #009939 1.5pt;padding:0in 0in 0in 0in">
<p class="MsoNormal"><span style="font-family:Helvetica;color:#555555"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |<u></u><u></u></span></p>
</td>
<td nowrap style="border:none;border-top:solid #eeb211 1.5pt;padding:0in 0in 0in 0in">
<p class="MsoNormal"><span style="font-family:Helvetica;color:#555555"> <a href="tel:408-460-2413" target="_blank">408-460-2413</a><u></u><u></u></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</div>
</div>
</div></div></div>
</div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Teresa Johnson |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"> 408-460-2413</td></tr></tbody></table></span></div>
</div></div>