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

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 21 09:10:15 PST 2018


yaxunl added inline comments.


================
Comment at: lib/CodeGen/CGCall.cpp:3505
+    if (AS != LangAS::Default && AS != LangAS::opencl_private &&
+        AS != CGM.getASTAllocaAddressSpace())
+      Flag = CallArg::ByValArgNeedsCopy;
----------------
rjmccall wrote:
> This is an odd condition.  What are you really trying to express here?  Something about the IR address space that the AST address space maps to?
> 
> The condition `AS != LangAS::Default` kills the optimization for all practical purposes, by the way, so something does need to change here.
> 
> I will note that if CallArg could take an LValue, neither this nor the alignment check would be required here; they'd just be done by the call-emission code.
This checks if an indirect by val arg can omit the copying. If the arg is in alloca or default addr space, the backend is able to copy it, so no explicit copying is needed by clang. Otherwise we need clang to insert copying.

I will try to replace Flag with LVal and see if it simplifies things.


https://reviews.llvm.org/D34367





More information about the cfe-commits mailing list