[PATCH] D16539: [FIX] 26194 - LLVM crash in CXXNameMangler::mangleType

Igor Chesnokov via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 1 06:51:10 PST 2016


ichesnokov removed rL LLVM as the repository for this revision.
ichesnokov updated this revision to Diff 46532.
ichesnokov added a comment.

Added generic variable support and checking address space to Microsoft mangler.
Test case updated.


http://reviews.llvm.org/D16539

Files:
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  test/CodeGenOpenCL/generic_mangling.cl
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===================================================================
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -363,7 +363,8 @@
       auto newEnd = std::remove(argv.begin(), argv.end(), nullptr);
       argv.resize(newEnd - argv.begin());
     }
-    return ExecuteCC1Tool(argv, argv[1] + 4);
+    int Result = ExecuteCC1Tool(argv, argv[1] + 4);
+    return Result; // Useful for debugging to set breakpoint here
   }
 
   bool CanonicalPrefixes = true;
Index: test/CodeGenOpenCL/generic_mangling.cl
===================================================================
--- test/CodeGenOpenCL/generic_mangling.cl
+++ test/CodeGenOpenCL/generic_mangling.cl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -ffake-address-space-map -emit-llvm -ffp-contract=off -x cl -cl-std=CL2.0 -o - %s | FileCheck %s
+
+// CHECK: define zeroext i1 @"\01?atomic_compare_exchange_strong@@$$J0YA_NPCU8CLglobalU?$_Atomic at H@__clang@@PAU9CLgenericHH at Z"(i32 addrspace(1)* %object, i32 addrspace(4)* %expected, i32 %desired)
+bool __attribute__((__overloadable__)) atomic_compare_exchange_strong(
+	volatile  __global atomic_int *object,
+  int  *expected,
+  int  desired)
+{
+  return atomic_compare_exchange_strong_explicit(
+        object, expected, desired, 1, 2);
+}
+
Index: lib/AST/MicrosoftMangle.cpp
===================================================================
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1383,6 +1383,37 @@
     }
   }
 
+  if (Quals.hasAddressSpace()) {
+    // Address space extension:
+    //
+    //   <type> ::= U <target-addrspace>
+    //   <type> ::= U <OpenCL-addrspace>
+    //   <type> ::= U <CUDA-addrspace>
+
+    SmallString<64> ASString;
+    unsigned AS = Quals.getAddressSpace();
+
+    if (Context.getASTContext().addressSpaceMapManglingFor(AS)) {
+      //  <target-addrspace> ::= "AS" <address-space-number>
+      unsigned TargetAS = Context.getASTContext().getTargetAddressSpace(AS);
+      ASString = "AS" + llvm::utostr_32(TargetAS);
+    } else {
+      switch (AS) {
+      default: llvm_unreachable("Not a language specific address space");
+        //  <OpenCL-addrspace> ::= "CL" [ "global" | "local" | "constant" ]
+      case LangAS::opencl_global:   ASString = "CLglobal";   break;
+      case LangAS::opencl_local:    ASString = "CLlocal";    break;
+      case LangAS::opencl_constant: ASString = "CLconstant"; break;
+      case LangAS::opencl_generic:  ASString = "CLgeneric";  break;
+        //  <CUDA-addrspace> ::= "CU" [ "device" | "constant" | "shared" ]
+      case LangAS::cuda_device:     ASString = "CUdevice";   break;
+      case LangAS::cuda_constant:   ASString = "CUconstant"; break;
+      case LangAS::cuda_shared:     ASString = "CUshared";   break;
+      }
+    }
+    Out << 'U' << ASString.size() << ASString;
+  }
+
   // FIXME: For now, just drop all extension qualifiers on the floor.
 }
 
Index: lib/AST/ItaniumMangle.cpp
===================================================================
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -1796,6 +1796,7 @@
       case LangAS::opencl_global:   ASString = "CLglobal";   break;
       case LangAS::opencl_local:    ASString = "CLlocal";    break;
       case LangAS::opencl_constant: ASString = "CLconstant"; break;
+      case LangAS::opencl_generic:  ASString = "CLgeneric";  break;
       //  <CUDA-addrspace> ::= "CU" [ "device" | "constant" | "shared" ]
       case LangAS::cuda_device:     ASString = "CUdevice";   break;
       case LangAS::cuda_constant:   ASString = "CUconstant"; break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16539.46532.patch
Type: text/x-patch
Size: 3604 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160201/e40a2b43/attachment.bin>


More information about the cfe-commits mailing list