summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnastasia Stulova <anastasia.stulova@arm.com>2019-03-19 16:50:21 +0000
committerAnastasia Stulova <anastasia.stulova@arm.com>2019-03-19 16:50:21 +0000
commit4ce581e5a9f902e5b6db0fd3115f5e914f105207 (patch)
tree287c73f2295624a992002939e68bdd4db271fec8
parent7a8e5051f412e669cbf60c5406c70239d6518eea (diff)
downloadbcm5719-llvm-4ce581e5a9f902e5b6db0fd3115f5e914f105207.tar.gz
bcm5719-llvm-4ce581e5a9f902e5b6db0fd3115f5e914f105207.zip
[Sema] Adjust addr space of reference operand in compound assignment
When we create overloads for the builtin compound assignment operators we need to preserve address space for the reference operand taking it from the argument that is passed in. Differential Revision: https://reviews.llvm.org/D59367 llvm-svn: 356475
-rw-r--r--clang/lib/Sema/SemaOverload.cpp18
-rw-r--r--clang/test/CodeGenOpenCLCXX/addrspace-operators.cl17
2 files changed, 20 insertions, 15 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 284642b976d..2409acd44f5 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -8513,17 +8513,16 @@ public:
Right < LastPromotedArithmeticType; ++Right) {
QualType ParamTypes[2];
ParamTypes[1] = ArithmeticTypes[Right];
-
+ auto LeftBaseTy = AdjustAddressSpaceForBuiltinOperandType(
+ S, ArithmeticTypes[Left], Args[0]);
// Add this built-in operator as a candidate (VQ is empty).
- ParamTypes[0] =
- S.Context.getLValueReferenceType(ArithmeticTypes[Left]);
+ ParamTypes[0] = S.Context.getLValueReferenceType(LeftBaseTy);
S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
/*IsAssigmentOperator=*/isEqualOp);
// Add this built-in operator as a candidate (VQ is 'volatile').
if (VisibleTypeConversionsQuals.hasVolatile()) {
- ParamTypes[0] =
- S.Context.getVolatileType(ArithmeticTypes[Left]);
+ ParamTypes[0] = S.Context.getVolatileType(LeftBaseTy);
ParamTypes[0] = S.Context.getLValueReferenceType(ParamTypes[0]);
S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
/*IsAssigmentOperator=*/isEqualOp);
@@ -8579,15 +8578,14 @@ public:
Right < LastPromotedIntegralType; ++Right) {
QualType ParamTypes[2];
ParamTypes[1] = ArithmeticTypes[Right];
-
+ auto LeftBaseTy = AdjustAddressSpaceForBuiltinOperandType(
+ S, ArithmeticTypes[Left], Args[0]);
// Add this built-in operator as a candidate (VQ is empty).
- ParamTypes[0] = S.Context.getLValueReferenceType(
- AdjustAddressSpaceForBuiltinOperandType(S, ArithmeticTypes[Left],
- Args[0]));
+ ParamTypes[0] = S.Context.getLValueReferenceType(LeftBaseTy);
S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
if (VisibleTypeConversionsQuals.hasVolatile()) {
// Add this built-in operator as a candidate (VQ is 'volatile').
- ParamTypes[0] = ArithmeticTypes[Left];
+ ParamTypes[0] = LeftBaseTy;
ParamTypes[0] = S.Context.getVolatileType(ParamTypes[0]);
ParamTypes[0] = S.Context.getLValueReferenceType(ParamTypes[0]);
S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
diff --git a/clang/test/CodeGenOpenCLCXX/addrspace-operators.cl b/clang/test/CodeGenOpenCLCXX/addrspace-operators.cl
index d212c233d1c..1f3389defde 100644
--- a/clang/test/CodeGenOpenCLCXX/addrspace-operators.cl
+++ b/clang/test/CodeGenOpenCLCXX/addrspace-operators.cl
@@ -14,6 +14,8 @@ public:
};
__global E globE;
+volatile __global int globVI;
+__global int globI;
//CHECK-LABEL: define spir_func void @_Z3barv()
void bar() {
C c;
@@ -25,13 +27,18 @@ void bar() {
c.OrAssign(a);
E e;
- // CHECK: store i32 1, i32* %e
+ //CHECK: store i32 1, i32* %e
e = b;
- // CHECK: store i32 0, i32 addrspace(1)* @globE
+ //CHECK: store i32 0, i32 addrspace(1)* @globE
globE = a;
- // FIXME: Sema fails here because it thinks the types are incompatible.
- //e = b;
- //globE = a;
+ //CHECK: store i32 %or, i32 addrspace(1)* @globI
+ globI |= b;
+ //CHECK: store i32 %add, i32 addrspace(1)* @globI
+ globI += a;
+ //CHECK: store volatile i32 %and, i32 addrspace(1)* @globVI
+ globVI &= b;
+ //CHECK: store volatile i32 %sub, i32 addrspace(1)* @globVI
+ globVI -= a;
}
//CHECK: define linkonce_odr void @_ZNU3AS41C6AssignE1E(%class.C addrspace(4)* %this, i32 %e)
OpenPOWER on IntegriCloud