From fdf389b9e41c6b1ff2b24fd56e5c253a8703092b Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Tue, 11 Nov 2008 20:21:14 +0000 Subject: [PATCH] Codegen support for fastcall & stdcall CC. Patch by Ilya Okonsky! llvm-svn: 59080 --- clang/lib/CodeGen/CodeGenModule.cpp | 5 ++++- clang/test/CodeGen/stdcall-fastcall.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 clang/test/CodeGen/stdcall-fastcall.c diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 3555ccd53a59..c4877a674533 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -252,7 +252,10 @@ void CodeGenModule::SetFunctionAttributes(const Decl *D, // Set the appropriate calling convention for the Function. if (D->getAttr()) - F->setCallingConv(llvm::CallingConv::Fast); + F->setCallingConv(llvm::CallingConv::X86_FastCall); + + if (D->getAttr()) + F->setCallingConv(llvm::CallingConv::X86_StdCall); } /// SetFunctionAttributesForDefinition - Set function attributes diff --git a/clang/test/CodeGen/stdcall-fastcall.c b/clang/test/CodeGen/stdcall-fastcall.c new file mode 100644 index 000000000000..a599405d2798 --- /dev/null +++ b/clang/test/CodeGen/stdcall-fastcall.c @@ -0,0 +1,17 @@ +// RUN: clang -emit-llvm < %s | grep 'fastcallcc' | count 4 +// RUN: clang -emit-llvm < %s | grep 'stdcallcc' | count 4 + +void __attribute__((fastcall)) f1(void); +void __attribute__((stdcall)) f2(void); +void __attribute__((fastcall)) f3(void) { + f1(); +} +void __attribute__((stdcall)) f4(void) { + f2(); +} + +int main(void) { + f3(); f4(); + return 0; +} + -- GitLab