Produce direct calls instead of alias to linkonce_odr functions

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Nov 5 13:04:01 PST 2013


Now with the patch actually attached.


On 5 November 2013 00:33, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:
>>> What happens is that at the end of GetOrCreateLLVMFunction we check if
>>> we have a decl defined in class and if so add it to
>>> DeferredDeclsToEmit. The net result is that we end up running
>>> replaceAllUsesWith twice when something in DeferredDeclsToEmit causes
>>> a new use of the destructor/constructor.
>>>
>>> Do you think this is OK? If not I can add a list of "DeclsToReplace"
>>> to Codegen and process that after EmitDeferred.
>>
>>
>> Ah, that makes sense.  Sounds fine, if a little bit silly.
>
> You were right. The example I tried worked because there was a call to
> GetOrCreateLLVMFunction before every try to emit the decl, so we would
> recreate the declaration before trying to emit it in EmitDeferred.
>
> With
>
> struct Option {
>   virtual ~Option() {}
> };
> template <class DataType> class opt : public Option {};
> template class opt<int>;
> bool handleOccurrence() {
>   Option x;
>   return true;
> }
>
> the template instantiation will not cause a declaration to be created
> and we assert when trying to replace the value the second time.
>
> The attached patch fixes this by doing all replacements after the
> deferred decls have been emitted. With this approach it should then be
> easy to also handle
>
> class foo {
>   ~foo();
> }
> class bar : public foo {
> }
>
> i.e., when we know a function is equal to one we don't have a definition for.
>
> Cheers,
> Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 7533 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131105/325b8781/attachment.obj>


More information about the cfe-commits mailing list