Restrict InstCombine from converting varargs to or from fixed args.
authorJim Grosbach <grosbach@apple.com>
Fri, 3 Feb 2012 00:00:55 +0000 (00:00 +0000)
committerJim Grosbach <grosbach@apple.com>
Fri, 3 Feb 2012 00:00:55 +0000 (00:00 +0000)
More targetted fix replacing d0e277d272d517ca1cda368267d199f0da7cad95.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149648 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineCalls.cpp

index a87fbbd9895fcb892e74adc28b38880c80645747..26e0a5528c31b59a492d0d23b824de31c6e75a38 100644 (file)
@@ -1104,6 +1104,13 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
     PointerType *APTy = cast<PointerType>(CS.getCalledValue()->getType());
     if (FT->isVarArg()!=cast<FunctionType>(APTy->getElementType())->isVarArg())
       return false;
+
+    // If both the callee and the cast type are varargs, we still have to make
+    // sure the number of fixed parameters are the same or we have the same
+    // ABI issues as if we introduce a varargs call.
+    if (FT->getNumParams() !=
+        cast<FunctionType>(APTy->getElementType())->getNumParams())
+      return false;
   }
       
   if (FT->getNumParams() < NumActualArgs && FT->isVarArg() &&