<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2017-01-04 19:12 GMT+01:00 John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span class=""><blockquote type="cite"><div>On Jan 4, 2017, at 4:41 AM, Piotr Padlewski <<a href="mailto:piotr.padlewski@gmail.com" target="_blank">piotr.padlewski@gmail.com</a>> wrote:</div><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2017-01-03 16:42 GMT+01:00 John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span><blockquote type="cite"><div>On Jan 3, 2017, at 7:23 AM, Piotr Padlewski <<a href="mailto:piotr.padlewski@gmail.com" target="_blank">piotr.padlewski@gmail.com</a>> wrote:</div><br class="m_-8621745499947790321m_6062852043208162211Apple-interchange-newline"><div><div dir="ltr">Maybe there is something I am missing, but I though vtables are being generated at the end of translation unit. <div>If there is nothing clang emits after vtable (maybe except inline virtual functions if they are reffered by vtable), then if there is a direct call to inline function, the function has to be emitted before</div><div>vtables. </div></div></div></blockquote><div><br></div></span>This is a fixed-point(-ish) problem: emitting a v-table can require more virtual functions which can require more v-tables.  So we just add stuff to queues and drain all the queues in a loop.</div><div><span><br><blockquote type="cite"><div><div dir="ltr"><div>I would like to emit available_externally vtable only if all inline virtual functions has been emitted.</div><div>It seems that I find function like virtual default destructor, that should be emitted before vtables (because there is implicit destructor call), but isDeclaration() return true for it.</div></div></div></blockquote><div><br></div></span>You cannot rely on exact order like this in the normal emission code.  IRGen does not and will not guarantee it.</div><div><br></div><div>You could make a separate pass after the lazy-emission loop.</div><span class="m_-8621745499947790321HOEnZb"><font color="#888888"><div><br></div><div>John.</div></font></span><span><div><br></div></span></div></blockquote><div>Thanks John, that would make sense. By 'separate pass' you mean do it in CodeGenModule::Release?</div></div></div></div></div></blockquote><div><br></div></span>Immediately after EmitDeferred(), yes.  (But as a separate function, please.)</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>John.</div></font></span></div></blockquote><div><br></div><div>Of course. Thanks Mehdi and John! </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span class=""><div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Piotr</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span><div><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>Test case like:</div><div><br></div><div><div>struct A {</div><div>  virtual void foo();</div><div>  virtual ~A() {};</div><div>};</div><div><br></div><div>void test() {</div><div>  A a; // This will force emit of A's destructor.</div><div>}</div></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-01-03 3:55 GMT+01:00 Mehdi Amini <span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
> On Dec 30, 2016, at 10:38 AM, Piotr Padlewski via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br>
><br>
> Hi,<br>
> I would like to check if there is inline virtual function that was not emitted.<br>
><br>
> I tried to do something like this based on CodeGenModule::GetOrCreateLLVM<wbr>Function:<br>
><br>
>       StringRef Name = CGM.getMangledName(VFunction);<br>
>       auto *Entry = CGM.GetGlobalValue(Name);<br>
><br>
>       // If function doesn't exist or doesn't have a definition.<br>
>       if (!Entry || Entry->isDeclaration())<br>
>         return true;<br>
><br>
> But Entry->isDeclaration() returns True for functions that I would expect to be emited.<br>
> What is the proper way of checking that?<br>
<br>
</span>isDeclaration() only returns true for a function that does not have a body / hasn’t been materialized yet. Do you observe that it is not the case in practice? Or are you trying to look if a function will be emitted by clang but hasn’t already?<br>
<br>
—<br>
<span class="m_-8621745499947790321m_6062852043208162211HOEnZb"><font color="#888888">Mehdi<br>
<br>
</font></span></blockquote></div><br></div>
</div></blockquote></div><br></span></div></blockquote></div><br></div></div>
</div></blockquote></div><br></span></div></blockquote></div><br></div></div>