[PATCH] D34367: CodeGen: Fix address space of indirect function argument

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 19 14:18:35 PDT 2017

yaxunl created this revision.

The byval function argument is in alloca address space in LLVM IR. However,
during Clang codegen for C++, the address space of indirect function argument
should match its address space in the source code, even for byval argument.
This is because destructor of the byval argument may be called in the caller
function, and address of the byval argument may be taken, in either case
the byval function argument is expected to be in its original address space,
not the alloca address space.

Also, the non-byval indirect function argument should be in the default address
space instead of alloca address space, since the argument is not necessarily
an alloca.

Therefore, the byval function argument should be mapped to the temp var
casted to default address space. The caller will cast it to alloca addr space
when passing it to the callee. In the callee, the argument is also casted to the
default address space and used.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34367.103103.patch
Type: text/x-patch
Size: 9043 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170619/6cbab1a8/attachment-0001.bin>

More information about the cfe-commits mailing list