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

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 25 13:03:19 PDT 2017

rjmccall added inline comments.

Comment at: lib/CodeGen/CGCall.cpp:3861
                < Align.getQuantity()) ||
             (ArgInfo.getIndirectByVal() && (RVAddrSpace != ArgAddrSpace))) {
           // Create an aligned temporary, and copy to it.
yaxunl wrote:
> rjmccall wrote:
> > This should be comparing AST address spaces.
> The AST address space of RV cannot be obtained through `CGFunctionInfo::const_arg_iterator it` and `it->type` since `it->type` takes type of 
> ```
> ImplicitCastExpr 0x60a9ff0 <col:5> 'struct S':'struct S' <LValueToRValue>
>     `-DeclRefExpr 0x60a9f28 <col:5> '__global struct S':'__global struct S' lvalue Var 0x607efb0
> ```
> and the original addr space is lost due to LValueToRValue cast.
> To get the AST addr space of RV, it seems I need to save the argument Expr in CallArgList and get it from Expr.
I think your last two comments are related.  I'm not sure why we haven't copied into a temporary here, and if we had, the assumption of LangAS::Default would be fine.  Would you mind doing the investigation there?


More information about the cfe-commits mailing list