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

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 11 08:17:31 PDT 2017


yaxunl marked 3 inline comments as done.
yaxunl added inline comments.


================
Comment at: lib/CodeGen/CGCall.cpp:1605
+              ? CGM.getDataLayout().getAllocaAddrSpace()
+              : getContext().getTargetAddressSpace(LangAS::Default));
       break;
----------------
rjmccall wrote:
> yaxunl wrote:
> > rjmccall wrote:
> > > Everything about your reasoning seems to apply to normal indirect arguments, too.
> > non-byval indirect argument is normally in default address space instead of alloca address space. For example,
> > 
> > 
> > ```
> > struct A { int a;};
> > void f(A &x);
> > ```
> > `x` is an indirect argument but should not be in alloca addr space, since the caller may pass a reference to a global variable.
> 'x' is not an indirect argument in this context.  It is a direct argument that happens to be of reference type.
> 
> A normal Indirect argument is when the ABI says an argument should implicitly be passed as a pointer to a temporary.  IndirectByVal is when the ABI says that something should be passed directly in the arguments area of the stack.  Some targets never use indirect arguments for normal C cases, but they're still used for direct non-POD arguments in C++.
You are right. Fixed.


https://reviews.llvm.org/D34367





More information about the cfe-commits mailing list