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

2018-03-07 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL326946: CodeGen: Fix address space of indirect function argument (authored by yaxunl, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D34367?vs

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

2018-03-07 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision. rjmccall added a comment. This revision is now accepted and ready to land. Thanks. LGTM! https://reviews.llvm.org/D34367 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/

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

2018-03-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 137460. yaxunl marked an inline comment as done. yaxunl edited the summary of this revision. yaxunl added a comment. Added comment about emit non-null argument check. https://reviews.llvm.org/D34367 Files: lib/CodeGen/CGAtomic.cpp lib/CodeGen/CGCall.cpp

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

2018-03-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: lib/CodeGen/CGCall.cpp:3427 (void)InitialArgSize; -RValue RVArg = Args.back().RV; -EmitNonNullArgCheck(RVArg, ArgTypes[Idx], (*Arg)->getExprLoc(), AC, -ParamsToSkip + Idx); -// @llvm.objectsize s

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

2018-03-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 137421. yaxunl marked an inline comment as done. yaxunl added a comment. Revised by John's comments. Removed CallArg::getAggregateAddress(). https://reviews.llvm.org/D34367 Files: lib/CodeGen/CGAtomic.cpp lib/CodeGen/CGCall.cpp lib/CodeGen/CGCall.h l

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

2018-03-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 20 inline comments as done. yaxunl added inline comments. Comment at: lib/CodeGen/CGCall.h:248 + return HasLV ? LV.getAddress() : RV.getAggregateAddress(); +} + rjmccall wrote: > Part of my thinking in suggesting this representation change

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

2018-03-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment. I'm sorry, I did a review of your patch on Phabricator but apparently never submitted it. Comment at: lib/CodeGen/CGCall.h:219 + RValue RV; + LValue LV; /// The l-value from which the argument is derived. +}; This could

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

2018-03-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 137279. yaxunl added a comment. Clean up CallArg::getRValue() so that it always return independent value. https://reviews.llvm.org/D34367 Files: lib/CodeGen/CGAtomic.cpp lib/CodeGen/CGCall.cpp lib/CodeGen/CGCall.h lib/CodeGen/CGClass.cpp lib/CodeGe

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

2018-02-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 136301. yaxunl added a comment. Revised by John's comments. Added CallArg::copyInto and modified CallArg::getRValue() to return an independent r-value by default. However some cases expecting l-value not copied, therefore I added an optional argument to Call

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

2018-02-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 135499. yaxunl added a comment. sync to ToT. https://reviews.llvm.org/D34367 Files: lib/CodeGen/CGAtomic.cpp lib/CodeGen/CGCall.cpp lib/CodeGen/CGCall.h lib/CodeGen/CGClass.cpp lib/CodeGen/CGDecl.cpp lib/CodeGen/CGExprCXX.cpp lib/CodeGen/CGGPUB

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

2018-02-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: lib/CodeGen/CGCall.cpp:3446 + return LV.asAggregateRValue(); +} + No, I don't think this is right. This method should always return an independent RValue; if the CallArg is storing an LValue, it should copy from it

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

2018-02-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 135474. yaxunl added a comment. Revised by John's comments. https://reviews.llvm.org/D34367 Files: lib/CodeGen/CGAtomic.cpp lib/CodeGen/CGCall.cpp lib/CodeGen/CGCall.h lib/CodeGen/CGClass.cpp lib/CodeGen/CGDecl.cpp lib/CodeGen/CGExprCXX.cpp lib

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

2018-02-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 135301. yaxunl added a comment. Replace Flag with LValue in CallArg. https://reviews.llvm.org/D34367 Files: lib/CodeGen/CGCall.cpp lib/CodeGen/CGCall.h lib/CodeGen/CGClass.cpp lib/CodeGen/CGDecl.cpp lib/CodeGen/CGObjCGNU.cpp lib/CodeGen/ItaniumCX

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

2018-02-21 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: lib/CodeGen/CGCall.cpp:3510 + args.add(RValue::getAggregate(Dest.getAddress()), type, L); } return; Please move all this conditionality to the call-emission code; just check whether you have a load of an

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

2018-02-21 Thread Yaxun Liu via Phabricator via cfe-commits
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 condi

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

2018-02-21 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: lib/CodeGen/CGCall.cpp:3505 +if (AS != LangAS::Default && AS != LangAS::opencl_private && +AS != CGM.getASTAllocaAddressSpace()) + Flag = CallArg::ByValArgNeedsCopy; This is an odd condition. What are

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

2018-02-20 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 135109. yaxunl added a comment. Extends NeedsCopy of CallArg for indirect byval arguments. https://reviews.llvm.org/D34367 Files: lib/CodeGen/CGCall.cpp lib/CodeGen/CGCall.h lib/CodeGen/CGClass.cpp lib/CodeGen/CGDecl.cpp lib/CodeGen/CGObjCGNU.cpp

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

2018-02-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment. In https://reviews.llvm.org/D34367#1009021, @rjmccall wrote: > That's not really okay; there are some places that make guarantees about > call-argument ordering, and in general we want that to be decided at a higher > level, rather than having a particular order forced i

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

2018-02-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment. That's not really okay; there are some places that make guarantees about call-argument ordering, and in general we want that to be decided at a higher level, rather than having a particular order forced in corner cases just to satisfy a lower-level implementation requi

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

2018-02-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments. Comment at: lib/CodeGen/CGCall.h:211 + push_back(CallArg(rvalue, type, needscopy, AS)); } rjmccall wrote: > Ah, I think I understand what's going on here now. "indirect byval" > arguments include an implicit copy to the

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

2018-02-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 134416. yaxunl edited the summary of this revision. yaxunl added a comment. Revised by John's comments. Removed address space from CallArg and added l-value expression instead. https://reviews.llvm.org/D34367 Files: lib/CodeGen/CGCall.cpp lib/CodeGen/CG

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

2017-09-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: lib/CodeGen/CGCall.h:211 + push_back(CallArg(rvalue, type, needscopy, AS)); } Ah, I think I understand what's going on here now. "indirect byval" arguments include an implicit copy to the stack, and the co

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

2017-08-31 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 113443. yaxunl added a comment. Revised by John's comments. https://reviews.llvm.org/D34367 Files: lib/CodeGen/CGCall.cpp lib/CodeGen/CGCall.h lib/CodeGen/CGDecl.cpp test/CodeGenCXX/amdgcn-func-arg.cpp test/CodeGenOpenCL/addr-space-struct-arg.cl I

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

2017-08-31 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl 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:

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

2017-08-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments. Comment at: lib/CodeGen/CGCall.cpp:3861 < Align.getQuantity()) || (ArgInfo.getIndirectByVal() && (RVAddrSpace != ArgAddrSpace))) { // Create an aligned temporary, and copy to it. rjmccall wrote

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

2017-08-25 Thread John McCall via Phabricator via cfe-commits
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

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

2017-08-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done. yaxunl added inline comments. Comment at: lib/CodeGen/CGCall.cpp:3861 < Align.getQuantity()) || (ArgInfo.getIndirectByVal() && (RVAddrSpace != ArgAddrSpace))) { // Create an aligned temporary, and co

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

2017-08-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 6 inline comments as done. yaxunl added inline comments. Comment at: lib/CodeGen/CGCall.cpp:3851 + ->getType() + ->getPointerAddressSpace(); const unsigned ArgAddrSpace = --

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

2017-08-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: lib/CodeGen/CGCall.cpp:3851 + ->getType() + ->getPointerAddressSpace(); const unsigned ArgAddrSpace = yaxunl wrote: > rjmccall wro

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

2017-08-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 5 inline comments as done. yaxunl added inline comments. Comment at: lib/CodeGen/CGCall.cpp:3832 + "indirect-arg-temp"); +IRCallArgs[FirstIRArg] = CastToAllocaAddrSpace(Addr.getPointer()); rjmccall wrote

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

2017-07-12 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: lib/CodeGen/CGCall.cpp:3832 + "indirect-arg-temp"); +IRCallArgs[FirstIRArg] = CastToAllocaAddrSpace(Addr.getPointer()); Isn't the original code here correct? You're basical

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

2017-07-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 106030. yaxunl marked an inline comment as done. yaxunl edited the summary of this revision. yaxunl added a comment. Always put indirect arg in alloca addr space. https://reviews.llvm.org/D34367 Files: lib/CodeGen/CGCall.cpp lib/CodeGen/CGDecl.cpp test

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

2017-07-11 Thread Yaxun Liu via Phabricator via cfe-commits
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

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

2017-06-20 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: lib/CodeGen/CGCall.cpp:1605 + ? CGM.getDataLayout().getAllocaAddrSpace() + : getContext().getTargetAddressSpace(LangAS::Default)); break; yaxunl wrote: > rjmccall wrote: > > Everything a

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

2017-06-20 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments. Comment at: lib/CodeGen/CGCall.cpp:1605 + ? CGM.getDataLayout().getAllocaAddrSpace() + : getContext().getTargetAddressSpace(LangAS::Default)); break; rjmccall wrote: > Everything about your reasoning

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

2017-06-20 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: lib/CodeGen/CGCall.cpp:1605 + ? CGM.getDataLayout().getAllocaAddrSpace() + : getContext().getTargetAddressSpace(LangAS::Default)); break; Everything about your reasoning seems to apply t

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

2017-06-19 Thread Yaxun Liu via Phabricator via cfe-commits
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 byva