[PATCH] D101389: [clang][CodeGen] Fix address space for sret

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 29 07:45:32 PDT 2021


yaxunl abandoned this revision.
yaxunl added a comment.

In D101389#2724757 <https://reviews.llvm.org/D101389#2724757>, @rjmccall wrote:

> In D101389#2724700 <https://reviews.llvm.org/D101389#2724700>, @yaxunl wrote:
>
>> In D101389#2724636 <https://reviews.llvm.org/D101389#2724636>, @rjmccall wrote:
>>
>>> I think this is intentional; requiring the indirect-result parameter to be in the alloca address space would prevent direct initialization of non-temporary memory, which is an important optimization in C++.
>>
>> You mean situations like this? https://godbolt.org/z/KnPs6znK8
>>
>> Address of a global variable is directly passed as the sret arg to the function returning a struct, instead of creating a temporary struct variable and passing its address as the sret arg?
>
> That's one specific case of copy-elision, but there are others, e.g.: https://godbolt.org/z/boTeMseaM
>
> I suppose you could disable general copy-elision.  But don't you have aggressive optimizations to strength-reduce generic pointer operations?

Thanks for the example. I agree that sret should be in default addr space.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101389/new/

https://reviews.llvm.org/D101389



More information about the cfe-commits mailing list