<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 3, 2017, at 7:23 AM, Piotr Padlewski <<a href="mailto:piotr.padlewski@gmail.com" class="">piotr.padlewski@gmail.com</a>> wrote:</div><br class="Apple-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><br class=""></div>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><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><br class=""></div>You cannot rely on exact order like this in the normal emission code.  IRGen does not and will not guarantee it.</div><div><br class=""></div><div>You could make a separate pass after the lazy-emission loop.</div><div><br class=""></div><div>John.</div><div><br 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" 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::<wbr class="">GetOrCreateLLVMFunction:<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="HOEnZb"><font color="#888888" class="">Mehdi<br class="">
<br class="">
</font></span></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>