]> granicus.if.org Git - clang/commitdiff
[OpenCL] Fix bug in mergeTypes which causes equivalent types treated as different.
authorYaxun Liu <Yaxun.Liu@amd.com>
Thu, 28 Apr 2016 17:34:57 +0000 (17:34 +0000)
committerYaxun Liu <Yaxun.Liu@amd.com>
Thu, 28 Apr 2016 17:34:57 +0000 (17:34 +0000)
When comparing unqualified types, canonical types should be used, otherwise equivalent types may be treated as different type.

Differential Revision: http://reviews.llvm.org/D19662

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

lib/AST/ASTContext.cpp
test/CodeGenOpenCL/address-spaces-conversions.cl

index fb4c80bd7fdac65fe451885913a0fd08061c0ed7..4f7f8ee8b8dee69242b5582ce2e8b33cd336c100 100644 (file)
@@ -7618,7 +7618,7 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
   Qualifiers RQuals = RHSCan.getLocalQualifiers();
   if (LQuals != RQuals) {
     if (getLangOpts().OpenCL) {
-      if (LHS.getUnqualifiedType() != RHS.getUnqualifiedType() ||
+      if (LHSCan.getUnqualifiedType() != RHSCan.getUnqualifiedType() ||
           LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers())
         return QualType();
       if (LQuals.isAddressSpaceSupersetOf(RQuals))
index bcd0267e8bed1c78341247f17151bbf19ba7e87a..c947db41e070ec8a2e9b4926edaebf696e3cfdde 100644 (file)
@@ -63,7 +63,16 @@ void test_ternary(void) {
   // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 addrspace(4)*
   // CHECK: phi
   // CHECK: store
-  
+
+  typedef int int_t;
+  global int_t *var_glob_typedef;
+  var_gen = var_gen ? var_gen : var_glob_typedef; // operands of overlapping addr spaces and equivalent types
+  // CHECK: icmp
+  // CHECK-NOT: bitcast
+  // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 addrspace(4)*
+  // CHECK: phi
+  // CHECK: store
   var_gen_v = var_gen ? var_gen : var_gen_f; // operands of the same addr space and different types
   // CHECK: icmp
   // CHECK: %{{.+}} = bitcast i32 addrspace(4)* %{{.+}} to i8 addrspace(4)*