r267906 - [OpenCL] Fix bug in mergeTypes which causes equivalent types treated as different.
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 28 10:34:58 PDT 2016
Author: yaxunl
Date: Thu Apr 28 12:34:57 2016
New Revision: 267906
URL: http://llvm.org/viewvc/llvm-project?rev=267906&view=rev
Log:
[OpenCL] Fix bug in mergeTypes which causes equivalent types treated as different.
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
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=267906&r1=267905&r2=267906&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Apr 28 12:34:57 2016
@@ -7618,7 +7618,7 @@ QualType ASTContext::mergeTypes(QualType
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))
Modified: cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl?rev=267906&r1=267905&r2=267906&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl Thu Apr 28 12:34:57 2016
@@ -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)*
More information about the cfe-commits
mailing list