[PATCH] ArgumentPromotion: Avoid invalidating the IR if a function's second argument is sret.

Reid Kleckner rnk at google.com
Wed Jun 10 10:57:27 PDT 2015


First, the limitation that sret be parameter 1 or 2 is artificial. At the time, I didn't see how it could appear on any other parameter and I tried to make the most minimal change. Now we have a reason to generalize to other parameters. That said, all the backends handle sret appearing on any parameter, because the first parameter can be split up into multiple MVTs. Consider passing i64 as the first parameter on a 32-bit platform. So, we could lift the verifier limitation.

Second, could argpromotion just drop sret in this case? sret does two things: it's equivalent to noalias, and it ensures that the sret pointer is returned in eax. If all uses of the function are internal, dropping sret is conservatively correct and reduces register pressure. We don't leverage that eax return because it would be an ABI break with old LLVMs, so we can replace sret with noalias without losing any power.

Finally, if you like having argpromotion canonicalize sret to be the first parameter, I guess that's also kind of nice, so we could continue on this way. :)


================
Comment at: lib/IR/Function.cpp:157-158
@@ -156,4 +156,2 @@
   if (!getType()->isPointerTy()) return false;
-  if (this != getParent()->arg_begin())
-    return false; // StructRet param must be first param
   return getParent()->getAttributes().
----------------
Oops, that's just a bug.

http://reviews.llvm.org/D10353

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list