Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PR40778][Sema] Adjust addr space of operands in builtin operators.
Adjust address space for references and pointer operands of builtin operators. Currently this change only fixes addr space in assignment (= and |=) operator, that is needed for the test case reported in the bug. Wider support for all other operations will follow. Differential Revision: https://reviews.llvm.org/D58719 llvm-svn: 355608
- Loading branch information
Anastasia Stulova
committed
Mar 7, 2019
1 parent
95817d3
commit 27e5c21
Showing
2 changed files
with
60 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//RUN: %clang_cc1 %s -triple spir -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s | ||
|
||
enum E { | ||
a, | ||
b, | ||
}; | ||
|
||
class C { | ||
public: | ||
void Assign(E e) { me = e; } | ||
void OrAssign(E e) { mi |= e; } | ||
E me; | ||
int mi; | ||
}; | ||
|
||
__global E globE; | ||
//CHECK-LABEL: define spir_func void @_Z3barv() | ||
void bar() { | ||
C c; | ||
//CHECK: addrspacecast %class.C* %c to %class.C addrspace(4)* | ||
//CHECK: call void @_ZNU3AS41C6AssignE1E(%class.C addrspace(4)* %{{[0-9]+}}, i32 0) | ||
c.Assign(a); | ||
//CHECK: addrspacecast %class.C* %c to %class.C addrspace(4)* | ||
//CHECK: call void @_ZNU3AS41C8OrAssignE1E(%class.C addrspace(4)* %{{[0-9]+}}, i32 0) | ||
c.OrAssign(a); | ||
|
||
E e; | ||
// CHECK: store i32 1, i32* %e | ||
e = b; | ||
// 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: define linkonce_odr void @_ZNU3AS41C6AssignE1E(%class.C addrspace(4)* %this, i32 %e) | ||
//CHECK: [[E:%[0-9]+]] = load i32, i32* %e.addr | ||
//CHECK: %me = getelementptr inbounds %class.C, %class.C addrspace(4)* %this1, i32 0, i32 0 | ||
//CHECK: store i32 [[E]], i32 addrspace(4)* %me | ||
|
||
//CHECK define linkonce_odr void @_ZNU3AS41C8OrAssignE1E(%class.C addrspace(4)* %this, i32 %e) | ||
//CHECK: [[E:%[0-9]+]] = load i32, i32* %e.addr | ||
//CHECK: %mi = getelementptr inbounds %class.C, %class.C addrspace(4)* %this1, i32 0, i32 1 | ||
//CHECK: [[MI:%[0-9]+]] = load i32, i32 addrspace(4)* %mi | ||
//CHECK: %or = or i32 [[MI]], [[E]] |