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

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 21 12:14:23 PST 2018


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 aggregate l-value and, if so, add the LValue as an unloaded aggregate to the argument list.


================
Comment at: lib/CodeGen/CGCall.h:220
+    CallArg(RValue rv, QualType ty, LValue _LV = LValue{})
+        : RV(rv), Ty(ty), LV(_LV) {}
+    bool hasLValue() const { return LV.getPointer(); }
----------------
It should be either an RValue or an LValue, not both.  The client needs to do different things in the different cases.  But you should add a convenience method for getting the argument as an RValue that either returns the stored RValue or copies out of the stored LValue, and most of the cases can just use that.

Just overload the constructor and CallArgList::add.  I would call the latter `addUncopiedAggregate`.


https://reviews.llvm.org/D34367





More information about the cfe-commits mailing list