[PATCH] Promote NPCs used as arguments to variadic functions

Richard Smith richard at metafoo.co.uk
Tue Oct 7 17:08:21 PDT 2014


I wonder whether it makes sense to restrict this to 64-bit MSVC platforms, since it's not really a problem elsewhere (other platforms have a sane `NULL`) and it presumably generates marginally worse code. Plus if we start doing this on, say, Mac OS, it'll make it harder for people to spot they have a bug until they port to another system.

================
Comment at: lib/CodeGen/CGCall.cpp:2721
@@ +2720,3 @@
+                                 Expr::NPC_ValueDependentIsNotNull)) {
+    return getContext().getIntPtrType();
+  }
----------------
Is there any way we can check that the current target permits this? (That is, that widening an integer argument to pointer width will never change the calling convention.)

================
Comment at: lib/CodeGen/CGCall.cpp:3024
@@ +3023,3 @@
+            V->getType()->isIntegerTy())
+          V = Builder.CreateZExtOrTrunc(V, ArgInfo.getCoerceToType());
+
----------------
Could just `CreateZExt` here. Presumably we should never coerce to a narrower type?

http://reviews.llvm.org/D5480






More information about the cfe-commits mailing list