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

Igor Chesnokov via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 3 04:57:53 PST 2016


ichesnokov updated the summary for this revision.
ichesnokov updated this revision to Diff 46772.
ichesnokov added a comment.

This diff adds mangling check test cases for Itanium and Microsoft manglers


http://reviews.llvm.org/D16539

Files:
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  test/CodeGenOpenCL/generic-mangling-itanium.cl
  test/CodeGenOpenCL/generic-mangling-microsoft.cl

Index: test/CodeGenOpenCL/generic-mangling-microsoft.cl
===================================================================
--- test/CodeGenOpenCL/generic-mangling-microsoft.cl
+++ test/CodeGenOpenCL/generic-mangling-microsoft.cl
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple i686-pc-windows-msvc -emit-llvm -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* %object, i32* %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: test/CodeGenOpenCL/generic-mangling-itanium.cl
===================================================================
--- test/CodeGenOpenCL/generic-mangling-itanium.cl
+++ test/CodeGenOpenCL/generic-mangling-itanium.cl
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -x cl -cl-std=CL2.0 -o - %s | FileCheck %s
+
+// CHECK: _Z30atomic_compare_exchange_strongPVU8CLglobalU7_AtomiciPU9CLgenericii
+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(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.46772.patch
Type: text/x-patch
Size: 3778 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160203/b0b59309/attachment.bin>


More information about the cfe-commits mailing list