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

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 28 21:04:45 PDT 2021


yaxunl added a comment.

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?

However, this is forbidden in CUDA/HIP: https://godbolt.org/z/1hjsrn9Tn

So can we assume sret arg is always in alloca addr space for CUDA/HIP?


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

https://reviews.llvm.org/D101389



More information about the cfe-commits mailing list