[PATCH] [ms-cxxabi] Construct and destroy call arguments in the correct order

Richard Smith richard at metafoo.co.uk
Tue Nov 26 16:20:49 PST 2013


  Looks fine, subject to also needing to handle `EmitCXXNewExpr`.


================
Comment at: lib/CodeGen/CGCall.cpp:1249
@@ -1248,1 +1248,3 @@
 
+  // Holds defered cleanups issued in the prologue.
+  SmallVector<std::pair<llvm::Value *, QualType>, 2> PrologueCleanups;
----------------
Two 'r's in deferred, please =)

================
Comment at: lib/CodeGen/CGCall.cpp:2032-2033
@@ +2031,4 @@
+
+  // We *have* to evaluate arguments from right to left in the MS C++ ABI,
+  // because arguments are destroyed left to right in the callee.
+  if (CGM.getTarget().getCXXABI().areArgsDestroyedLeftToRightInCallee()) {
----------------
There are other places that need updating for this: at least `EmitCXXNewExpr`, not sure if there are others.

================
Comment at: lib/CodeGen/CGCall.cpp:2038
@@ +2037,3 @@
+      CallExpr::const_arg_iterator Arg = ArgBeg + I;
+      EmitCallArg(Args, *Arg, ArgTypes[I]);
+      // Restore the debug location.
----------------
I assume you're going to need to update this again to perform all the allocas for a call, and then emit all the arguments, once we support `inalloca` here? (Otherwise the stack layout will be backwards.)

================
Comment at: lib/CodeGen/CGDecl.cpp:1649
@@ -1647,3 +1648,3 @@
     DeclPtr = Arg;
     // Push a destructor cleanup for this parameter if the ABI requires it.
     if (HasNonScalarEvalKind &&
----------------
Hmm, why do we only handle destructor cleanups in the callee-cleanup code? Do we have some common code we could reuse to perform the appropriate cleanup for the ARC cases too?


http://llvm-reviews.chandlerc.com/D2275



More information about the cfe-commits mailing list