]> granicus.if.org Git - clang/commitdiff
Codegen support for fastcall & stdcall CC.
authorAnton Korobeynikov <asl@math.spbu.ru>
Tue, 11 Nov 2008 20:21:14 +0000 (20:21 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Tue, 11 Nov 2008 20:21:14 +0000 (20:21 +0000)
Patch by Ilya Okonsky!

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

lib/CodeGen/CodeGenModule.cpp
test/CodeGen/stdcall-fastcall.c [new file with mode: 0644]

index 3555ccd53a593c748a26b17d4fe37756ee7a5765..c4877a6745337a53822e5b0321c4ce767f218caf 100644 (file)
@@ -252,7 +252,10 @@ void CodeGenModule::SetFunctionAttributes(const Decl *D,
 
   // Set the appropriate calling convention for the Function.
   if (D->getAttr<FastCallAttr>())
-    F->setCallingConv(llvm::CallingConv::Fast);
+    F->setCallingConv(llvm::CallingConv::X86_FastCall);
+
+  if (D->getAttr<StdCallAttr>())
+    F->setCallingConv(llvm::CallingConv::X86_StdCall);
 }
 
 /// SetFunctionAttributesForDefinition - Set function attributes
diff --git a/test/CodeGen/stdcall-fastcall.c b/test/CodeGen/stdcall-fastcall.c
new file mode 100644 (file)
index 0000000..a599405
--- /dev/null
@@ -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;
+}
+