[PATCH] Mangler: Don't prefix MS ABI names with a leading ? character

Reid Kleckner rnk at google.com
Thu Feb 19 16:34:06 PST 2015


- Remove the check for stdcall/fastcall mangling


http://reviews.llvm.org/D7775

Files:
  lib/IR/Mangler.cpp
  test/MC/COFF/symbol-mangling.ll
  test/MC/COFF/tricky-names.ll

Index: lib/IR/Mangler.cpp
===================================================================
--- lib/IR/Mangler.cpp
+++ lib/IR/Mangler.cpp
@@ -115,6 +115,12 @@
   StringRef Name = GV->getName();
   char Prefix = DL->getGlobalPrefix();
 
+  // Don't mangle Microsoft C++ names, which start with '?'.
+  if (Name.startswith("?")) {
+    OS << Name;
+    return;
+  }
+
   // Mangle functions with Microsoft calling conventions specially.  Only do
   // this mangling for x86_64 vectorcall and 32-bit x86.
   const Function *MSFunc = dyn_cast<Function>(GV);
Index: test/MC/COFF/symbol-mangling.ll
===================================================================
--- test/MC/COFF/symbol-mangling.ll
+++ test/MC/COFF/symbol-mangling.ll
@@ -4,14 +4,14 @@
 
 ; RUN: llc -filetype=asm -mtriple i686-pc-win32 %s -o - | FileCheck %s
 
-; CHECK: ?sayhi at A@@QBEXXZ
+; CHECK: "?sayhi at A@@QBEXXZ"
 
 %struct.A = type {}
 
 define i32 @main() {
 entry:
-  tail call void @"\01?sayhi at A@@QBEXXZ"(%struct.A* null)
+  tail call void @"?sayhi at A@@QBEXXZ"(%struct.A* null)
   ret i32 0
 }
 
-declare void @"\01?sayhi at A@@QBEXXZ"(%struct.A*)
+declare void @"?sayhi at A@@QBEXXZ"(%struct.A*)
Index: test/MC/COFF/tricky-names.ll
===================================================================
--- test/MC/COFF/tricky-names.ll
+++ test/MC/COFF/tricky-names.ll
@@ -3,14 +3,16 @@
 
 ; Check that we can roundtrip these names through our assembler.
 ; RUN: llc -mtriple=i686-pc-win32 %s -o - | llvm-mc -triple i686-pc-win32 -filetype=obj | llvm-readobj -t | FileCheck %s --check-prefix=READOBJ
+; RUN: llc -mtriple=x86_64-pc-win32 %s -o - | llvm-mc -triple x86_64-pc-win32 -filetype=obj | llvm-readobj -t | FileCheck %s --check-prefix=READOBJ
 
+; We don't need the \01 prefix for MSVC symbols using ?.
 
-@"\01??__E_Generic_object@?$_Error_objects at H@std@@YAXXZ" = global i32 0
+@"??__E_Generic_object@?$_Error_objects at H@std@@YAXXZ" = global i32 0
 @"\01__ZL16ExceptionHandlerP19_EXCEPTION_POINTERS at 4" = global i32 0
 @"\01 at foo.bar" = global i32 0
 
-define weak i32 @"\01??_B?$num_put at _WV?$back_insert_iterator at V?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@@std@@@std@@51"() section ".text" {
-  %a = load i32* @"\01??__E_Generic_object@?$_Error_objects at H@std@@YAXXZ"
+define weak i32 @"??_B?$num_put at _WV?$back_insert_iterator at V?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@@std@@@std@@51"() section ".text" {
+  %a = load i32* @"??__E_Generic_object@?$_Error_objects at H@std@@YAXXZ"
   %b = load i32* @"\01__ZL16ExceptionHandlerP19_EXCEPTION_POINTERS at 4"
   %c = load i32* @"\01 at foo.bar"
   %x = add i32 %a, %b

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7775.20357.patch
Type: text/x-patch
Size: 2620 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150220/3e683f11/attachment.bin>


More information about the llvm-commits mailing list