]> granicus.if.org Git - clang/commitdiff
Correct behavior of fastcall when default CC is set.
authorErich Keane <erich.keane@intel.com>
Tue, 24 Oct 2017 23:12:01 +0000 (23:12 +0000)
committerErich Keane <erich.keane@intel.com>
Tue, 24 Oct 2017 23:12:01 +0000 (23:12 +0000)
Fastcall doesn't support variadic function calls, so
setting the default calling convention to Fastcall would
result in incorrect code being emitted for these conditions.

This patch adds a 'variadic' test to the default calling conv
test, as well as fixes the behavior of fastcall.

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

lib/AST/ASTContext.cpp
test/CodeGenCXX/default_calling_conv.cpp

index a7ff9e10e9da26f290872cafd2428769105a2551..87d096dab008d68db1eff02b345f615a6e09238b 100644 (file)
@@ -9269,7 +9269,7 @@ CallingConv ASTContext::getDefaultCallingConvention(bool IsVariadic,
   case LangOptions::DCC_CDecl:
     return CC_C;
   case LangOptions::DCC_FastCall:
-    if (getTargetInfo().hasFeature("sse2"))
+    if (getTargetInfo().hasFeature("sse2") && !IsVariadic)
       return CC_X86FastCall;
     break;
   case LangOptions::DCC_StdCall:
index 95c214a223d4332457e8cba7ef01061080761852..15eedc8e318371e1d641b7242f45e14f8ab3e62e 100644 (file)
 // VECTORCALL: define x86_vectorcallcc void @_Z5test1v
 void test1() {}
 
+// fastcall, stdcall, and vectorcall all do not support variadic functions.
+// CDECL: define void @_Z12testVariadicz
+// FASTCALL: define void @_Z12testVariadicz
+// STDCALL: define void @_Z12testVariadicz
+// VECTORCALL: define void @_Z12testVariadicz
+void testVariadic(...){}
+
 // ALL: define void @_Z5test2v
 void __attribute__((cdecl)) test2() {}