[PATCH] CGCall: Factor out the logic mapping call arguments to LLVM IR arguments.

Reid Kleckner rnk at google.com
Thu Aug 21 15:10:57 PDT 2014

Comment at: lib/CodeGen/CGCall.cpp:1148-1150
@@ +1147,5 @@
+      for (; NumIRArgs > 0; --NumIRArgs) {
+        IRArgs[ArgNo].push_back(IRArgNo++);
+      }
Alexey Samsonov wrote:
> Reid Kleckner wrote:
> > Looks like all argument types consume either zero, one, or sequential IR arguments.  This only needs to store one number per AST-level argument. If there are zero IR args, use InvalidIndex. If there is one IR arg, store the IR arg number. If there are more than one, store the first IR arg number. The consumers can increment that during argument expansion.
> > 
> > Does that sound reasonable?
> Yes, I think the assumption that all IR arguments are sequential is reasonable. Currently, we would still need to do argument expansion both here, and in EmitPrologue/EmitCall methods. I think it makes to store the number of expanded arguments to assert that the numbers match (at least until we refactor terribly similar GetExpandedTypes / ExpandTypeFromArgs / ExpandTypeToArgs into a single routine and/or introduce a map "QualType -> number of arguments it expands to").
> What we can do is replace PaddingIRArgIndex and IRArgs vectors with a single vector of triples <PaddingIRArgIndex, FirstIRArgIndex, NumberOfIRArgs>. WDYT?
Yeah, sounds good.


More information about the cfe-commits mailing list