<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=""><div><blockquote type="cite" class=""><div class="">On Jan 4, 2017, at 4:41 AM, Piotr Padlewski <<a href="mailto:piotr.padlewski@gmail.com" class="">piotr.padlewski@gmail.com</a>> wrote:</div><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">2017-01-03 16:42 GMT+01:00 John McCall <span dir="ltr" class=""><<a href="mailto:rjmccall@apple.com" target="_blank" class="">rjmccall@apple.com</a>></span>:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Jan 3, 2017, at 7:23 AM, Piotr Padlewski <<a href="mailto:piotr.padlewski@gmail.com" target="_blank" class="">piotr.padlewski@gmail.com</a>> wrote:</div><br class="m_6062852043208162211Apple-interchange-newline"><div class=""><div dir="ltr" class="">Maybe there is something I am missing, but I though vtables are being generated at the end of translation unit. <div class="">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 class="">vtables. </div></div></div></blockquote><div class=""><br class=""></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 class=""><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">I would like to emit available_externally vtable only if all inline virtual functions has been emitted.</div><div class="">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 class=""><br class=""></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 class=""><br class=""></div><div class="">You could make a separate pass after the lazy-emission loop.</div><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">John.</div></font></span><span class=""><div class=""><br class=""></div></span></div></blockquote><div class="">Thanks John, that would make sense. By 'separate pass' you mean do it in CodeGenModule::Release?</div></div></div></div></div></blockquote><div><br class=""></div>Immediately after EmitDeferred(), yes. (But as a separate function, please.)</div><div><br class=""></div><div>John.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">Piotr</div><div class=""> </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" class=""><span class=""><div class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Test case like:</div><div class=""><br class=""></div><div class=""><div class="">struct A {</div><div class=""> virtual void foo();</div><div class=""> virtual ~A() {};</div><div class="">};</div><div class=""><br class=""></div><div class="">void test() {</div><div class=""> A a; // This will force emit of A's destructor.</div><div class="">}</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">2017-01-03 3:55 GMT+01:00 Mehdi Amini <span dir="ltr" class=""><<a href="mailto:mehdi.amini@apple.com" target="_blank" class="">mehdi.amini@apple.com</a>></span>:<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 Dec 30, 2016, at 10:38 AM, Piotr Padlewski via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank" class="">cfe-dev@lists.llvm.org</a>> wrote:<br class="">
><br class="">
> Hi,<br class="">
> I would like to check if there is inline virtual function that was not emitted.<br class="">
><br class="">
> I tried to do something like this based on CodeGenModule::GetOrCreateLLVM<wbr class="">Function:<br class="">
><br class="">
> StringRef Name = CGM.getMangledName(VFunction);<br class="">
> auto *Entry = CGM.GetGlobalValue(Name);<br class="">
><br class="">
> // If function doesn't exist or doesn't have a definition.<br class="">
> if (!Entry || Entry->isDeclaration())<br class="">
> return true;<br class="">
><br class="">
> But Entry->isDeclaration() returns True for functions that I would expect to be emited.<br class="">
> What is the proper way of checking that?<br class="">
<br class="">
</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 class="">
<br class="">
—<br class="">
<span class="m_6062852043208162211HOEnZb"><font color="#888888" class="">Mehdi<br class="">
<br class="">
</font></span></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></span></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>