[PATCH] Promote NPCs used as arguments to variadic functions

Reid Kleckner rnk at google.com
Thu Oct 9 11:50:50 PDT 2014


>>! In D5480#19, @rsmith wrote:
> 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.

OK, but there are other triples (WoA) that use the itanium environment that might have broken headers, so how about Windows platforms where pointer size != integer size? (aarch64, x86_64, ppc64)

================
Comment at: lib/CodeGen/CGCall.cpp:2721
@@ +2720,3 @@
+                                 Expr::NPC_ValueDependentIsNotNull)) {
+    return getContext().getIntPtrType();
+  }
----------------
rsmith wrote:
> 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.)
There is no such predicate currently. I don't think there is value in adding a predicate which will always return true for all current targets.

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

http://reviews.llvm.org/D5480






More information about the cfe-commits mailing list