diff options
author | Erich Keane <erich.keane@intel.com> | 2017-10-24 23:12:01 +0000 |
---|---|---|
committer | Erich Keane <erich.keane@intel.com> | 2017-10-24 23:12:01 +0000 |
commit | 5c484035ac41e9af5907ec574faa6e8c43cc00a2 (patch) | |
tree | 7e201d9454122b110001db7aa6a44c45bb41af4d | |
parent | 15627d62634ea98431990fff026a04629f9e378e (diff) | |
download | clang-5c484035ac41e9af5907ec574faa6e8c43cc00a2.tar.gz |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316528 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/ASTContext.cpp | 2 | ||||
-rw-r--r-- | test/CodeGenCXX/default_calling_conv.cpp | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index a7ff9e10e9..87d096dab0 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -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: diff --git a/test/CodeGenCXX/default_calling_conv.cpp b/test/CodeGenCXX/default_calling_conv.cpp index 95c214a223..15eedc8e31 100644 --- a/test/CodeGenCXX/default_calling_conv.cpp +++ b/test/CodeGenCXX/default_calling_conv.cpp @@ -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() {} |