Author: erichkeane Date: Tue Oct 24 16:12:01 2017 New Revision: 316528 URL: http://llvm.org/viewvc/llvm-project?rev=316528&view=rev Log: Correct behavior of fastcall when default CC is set.
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. Modified: cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/test/CodeGenCXX/default_calling_conv.cpp Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=316528&r1=316527&r2=316528&view=diff ============================================================================== --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Tue Oct 24 16:12:01 2017 @@ -9269,7 +9269,7 @@ CallingConv ASTContext::getDefaultCallin 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: Modified: cfe/trunk/test/CodeGenCXX/default_calling_conv.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/default_calling_conv.cpp?rev=316528&r1=316527&r2=316528&view=diff ============================================================================== --- cfe/trunk/test/CodeGenCXX/default_calling_conv.cpp (original) +++ cfe/trunk/test/CodeGenCXX/default_calling_conv.cpp Tue Oct 24 16:12:01 2017 @@ -10,6 +10,13 @@ // 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() {} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits