[PATCH] D42768: AST: add an extension to support SwiftCC on MS ABI

Saleem Abdulrasool via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 31 16:21:29 PST 2018


compnerd created this revision.
compnerd added a reviewer: rnk.
compnerd added a subscriber: troughton.

Since we are unable to mangle the SwiftCC CC in the function type,
provide an additional namespace qualifier to the decorated source 
of `__swift_cc` which serves as the CC identifier.  This is needed to
support swift on Windows.


Repository:
  rC Clang

https://reviews.llvm.org/D42768

Files:
  lib/AST/MicrosoftMangle.cpp
  test/CodeGenCXX/msabi-swiftcall-cc.cpp


Index: test/CodeGenCXX/msabi-swiftcall-cc.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/msabi-swiftcall-cc.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -emit-llvm %s -o - | FileCheck %s
+
+
+void __attribute__((__swiftcall__)) f(void) {}
+// CHECK-DAG: @"\01?f at __swift_cc@@YAXXZ"
+
Index: lib/AST/MicrosoftMangle.cpp
===================================================================
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1050,6 +1050,10 @@
     }
     DC = DC->getParent();
   }
+
+  if (const auto *FD = dyn_cast<FunctionDecl>(ND))
+    if (FD->getType()->getAs<FunctionType>()->getCallConv() == CC_Swift)
+      mangleSourceName("__swift_cc");
 }

 void MicrosoftCXXNameMangler::mangleCXXDtorType(CXXDtorType T) {
@@ -1959,6 +1963,10 @@
     mangleQualifiers(Quals, /*IsMember=*/false);
   }

+  // We currently mangle the SwiftCC as `__swift_cc` namespace on the decl.
+  if (CC == CC_Swift)
+    CC = CC_C;
+
   mangleCallingConvention(CC);

   // <return-type> ::= <type>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42768.132292.patch
Type: text/x-patch
Size: 1098 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180201/619ec354/attachment.bin>


More information about the cfe-commits mailing list