Skip to content

[SYCL] Remove ASFixer and DISABLE_INFER_AS support #893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions clang/lib/Basic/Targets/SPIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRTargetInfo : public TargetInfo {
TLSSupported = false;
VLASupported = false;
LongWidth = LongAlign = 64;
if (Triple.getEnvironment() == llvm::Triple::SYCLDevice &&
!getenv("DISABLE_INFER_AS")) {
if (Triple.getEnvironment() == llvm::Triple::SYCLDevice) {
AddrSpaceMap = &SYCLAddrSpaceMap;
} else {
AddrSpaceMap = &SPIRAddrSpaceMap;
Expand Down
5 changes: 0 additions & 5 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
#include "llvm/Passes/StandardInstrumentations.h"
#include "llvm/SYCL/ASFixer.h"
#include "llvm/Support/BuryPointer.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
Expand Down Expand Up @@ -854,8 +853,6 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,

case Backend_EmitBC:
if (LangOpts.SYCLIsDevice) {
if (getenv("DISABLE_INFER_AS"))
PerModulePasses.add(createASFixerPass());
PerModulePasses.add(createDeadCodeEliminationPass());
}
if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
Expand Down Expand Up @@ -1282,8 +1279,6 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(

case Backend_EmitBC:
if (LangOpts.SYCLIsDevice) {
if (getenv("DISABLE_INFER_AS"))
CodeGenPasses.add(createASFixerPass());
CodeGenPasses.add(createDeadCodeEliminationPass());
}
if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
Expand Down
20 changes: 9 additions & 11 deletions clang/lib/CodeGen/CGCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4316,17 +4316,15 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
deactivateArgCleanupsBeforeCall(*this, CallArgs);

// Addrspace cast to generic if necessary
if (!getenv("DISABLE_INFER_AS")) {
for (unsigned i = 0; i < IRFuncTy->getNumParams(); ++i) {
if (auto *PtrTy = dyn_cast<llvm::PointerType>(IRCallArgs[i]->getType())) {
auto *ExpectedPtrType =
cast<llvm::PointerType>(IRFuncTy->getParamType(i));
unsigned ValueAS = PtrTy->getAddressSpace();
unsigned ExpectedAS = ExpectedPtrType->getAddressSpace();
if (ValueAS != ExpectedAS) {
IRCallArgs[i] = Builder.CreatePointerBitCastOrAddrSpaceCast(
IRCallArgs[i], ExpectedPtrType);
}
for (unsigned i = 0; i < IRFuncTy->getNumParams(); ++i) {
if (auto *PtrTy = dyn_cast<llvm::PointerType>(IRCallArgs[i]->getType())) {
auto *ExpectedPtrType =
cast<llvm::PointerType>(IRFuncTy->getParamType(i));
unsigned ValueAS = PtrTy->getAddressSpace();
unsigned ExpectedAS = ExpectedPtrType->getAddressSpace();
if (ValueAS != ExpectedAS) {
IRCallArgs[i] = Builder.CreatePointerBitCastOrAddrSpaceCast(
IRCallArgs[i], ExpectedPtrType);
}
}
}
Expand Down
18 changes: 8 additions & 10 deletions clang/lib/CodeGen/CGExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1748,16 +1748,14 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr,
return;
}

if (!getenv("DISABLE_INFER_AS")) {
if (auto *PtrTy = dyn_cast<llvm::PointerType>(Value->getType())) {
auto *ExpectedPtrType =
cast<llvm::PointerType>(Addr.getType()->getElementType());
unsigned ValueAS = PtrTy->getAddressSpace();
unsigned ExpectedAS = ExpectedPtrType->getAddressSpace();
if (ValueAS != ExpectedAS) {
Value =
Builder.CreatePointerBitCastOrAddrSpaceCast(Value, ExpectedPtrType);
}
if (auto *PtrTy = dyn_cast<llvm::PointerType>(Value->getType())) {
auto *ExpectedPtrType =
cast<llvm::PointerType>(Addr.getType()->getElementType());
unsigned ValueAS = PtrTy->getAddressSpace();
unsigned ExpectedAS = ExpectedPtrType->getAddressSpace();
if (ValueAS != ExpectedAS) {
Value =
Builder.CreatePointerBitCastOrAddrSpaceCast(Value, ExpectedPtrType);
}
}
llvm::StoreInst *Store = Builder.CreateStore(Value, Addr, Volatile);
Expand Down
35 changes: 15 additions & 20 deletions clang/lib/CodeGen/CGStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1110,16 +1110,13 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
// rather than the value.
RValue Result = EmitReferenceBindingToExpr(RV);
llvm::Value *Val = Result.getScalarVal();
if (!getenv("DISABLE_INFER_AS")) {
if (auto *PtrTy = dyn_cast<llvm::PointerType>(Val->getType())) {
auto *ExpectedPtrType =
cast<llvm::PointerType>(ReturnValue.getType()->getElementType());
unsigned ValueAS = PtrTy->getAddressSpace();
unsigned ExpectedAS = ExpectedPtrType->getAddressSpace();
if (ValueAS != ExpectedAS) {
Val =
Builder.CreatePointerBitCastOrAddrSpaceCast(Val, ExpectedPtrType);
}
if (auto *PtrTy = dyn_cast<llvm::PointerType>(Val->getType())) {
auto *ExpectedPtrType =
cast<llvm::PointerType>(ReturnValue.getType()->getElementType());
unsigned ValueAS = PtrTy->getAddressSpace();
unsigned ExpectedAS = ExpectedPtrType->getAddressSpace();
if (ValueAS != ExpectedAS) {
Val = Builder.CreatePointerBitCastOrAddrSpaceCast(Val, ExpectedPtrType);
}
}
Builder.CreateStore(Val, ReturnValue);
Expand All @@ -1128,16 +1125,14 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
case TEK_Scalar:
{
llvm::Value *Val = EmitScalarExpr(RV);
if (!getenv("DISABLE_INFER_AS")) {
if (auto *PtrTy = dyn_cast<llvm::PointerType>(Val->getType())) {
auto *ExpectedPtrType =
cast<llvm::PointerType>(ReturnValue.getType()->getElementType());
unsigned ValueAS = PtrTy->getAddressSpace();
unsigned ExpectedAS = ExpectedPtrType->getAddressSpace();
if (ValueAS != ExpectedAS) {
Val = Builder.CreatePointerBitCastOrAddrSpaceCast(
Val, ExpectedPtrType);
}
if (auto *PtrTy = dyn_cast<llvm::PointerType>(Val->getType())) {
auto *ExpectedPtrType =
cast<llvm::PointerType>(ReturnValue.getType()->getElementType());
unsigned ValueAS = PtrTy->getAddressSpace();
unsigned ExpectedAS = ExpectedPtrType->getAddressSpace();
if (ValueAS != ExpectedAS) {
Val =
Builder.CreatePointerBitCastOrAddrSpaceCast(Val, ExpectedPtrType);
}
}
Builder.CreateStore(Val, ReturnValue);
Expand Down
1 change: 0 additions & 1 deletion clang/lib/CodeGen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ set(LLVM_LINK_COMPONENTS
Support
Target
TransformUtils
ASFixer
)

# In a standard Clang+LLVM build, we need to generate intrinsics before
Expand Down
8 changes: 3 additions & 5 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3775,10 +3775,8 @@ LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) {

if (Scope && Scope->isWorkGroup())
return LangAS::opencl_local;
if (!getenv("DISABLE_INFER_AS")) {
if (!D || D->getType().getAddressSpace() == LangAS::Default) {
return LangAS::opencl_global;
}
if (!D || D->getType().getAddressSpace() == LangAS::Default) {
return LangAS::opencl_global;
}
}

Expand Down Expand Up @@ -3807,7 +3805,7 @@ LangAS CodeGenModule::getStringLiteralAddressSpace() const {
// OpenCL v1.2 s6.5.3: a string literal is in the constant address space.
if (LangOpts.OpenCL)
return LangAS::opencl_constant;
if (LangOpts.SYCLIsDevice && !getenv("DISABLE_INFER_AS"))
if (LangOpts.SYCLIsDevice)
// If we keep a literal string in constant address space, the following code
// becomes illegal:
//
Expand Down
2 changes: 0 additions & 2 deletions clang/lib/Frontend/InitPreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1089,8 +1089,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
if (LangOpts.SYCLIsDevice) {
Builder.defineMacro("__SYCL_DEVICE_ONLY__", "1");
Builder.defineMacro("SYCL_EXTERNAL", "__attribute__((sycl_device))");
if (!getenv("DISABLE_INFER_AS"))
Builder.defineMacro("__SYCL_ENABLE_INFER_AS__", "1");
}
if (LangOpts.SYCLUnnamedLambda)
Builder.defineMacro("__SYCL_UNNAMED_LAMBDA__", "1");
Expand Down
89 changes: 30 additions & 59 deletions clang/test/CodeGenSYCL/address-space-new.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// RUN: DISABLE_INFER_AS=1 %clang_cc1 -triple spir64-unknown-linux-sycldevice -std=c++11 -fsycl-is-device -disable-llvm-passes -emit-llvm -x c++ %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-LEGACY
// RUN: %clang_cc1 -triple spir64-unknown-linux-sycldevice -std=c++11 -fsycl-is-device -disable-llvm-passes -emit-llvm -x c++ %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NEW
// RUN: %clang_cc1 -triple spir64-unknown-linux-sycldevice -std=c++11 -fsycl-is-device -disable-llvm-passes -emit-llvm -x c++ %s -o - | FileCheck %s

struct SpaceWaster {
int i, j;
Expand All @@ -19,8 +18,7 @@ void baz(Y &y) {

void test() {
static const int foo = 0x42;
// CHECK-LEGACY: @_ZZ4testvE3foo = internal constant i32 66, align 4
// CHECK-NEW: @_ZZ4testvE3foo = internal addrspace(1) constant i32 66, align 4
// CHECK: @_ZZ4testvE3foo = internal addrspace(1) constant i32 66, align 4

// Intentionally leave a part of an array uninitialized. This triggers a
// different code path contrary to a fully initialized array.
Expand All @@ -29,60 +27,49 @@ void test() {
11, 12, 13, 14, 15, 16, 17, 18, 19, 20
};
(void)bars;
// CHECK-LEGACY: @_ZZ4testvE4bars = internal constant <{ [21 x i32], [235 x i32] }> <{ [21 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20], [235 x i32] zeroinitializer }>, align 4
// CHECK-NEW: @_ZZ4testvE4bars = internal addrspace(1) constant <{ [21 x i32], [235 x i32] }> <{ [21 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20], [235 x i32] zeroinitializer }>, align 4
// CHECK: @_ZZ4testvE4bars = internal addrspace(1) constant <{ [21 x i32], [235 x i32] }> <{ [21 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20], [235 x i32] zeroinitializer }>, align 4

// CHECK: @[[STR:[.a-zA-Z0-9_]+]] = private unnamed_addr constant [14 x i8] c"Hello, world!\00", align 1

// CHECK-NEW: %i.ascast = addrspacecast i32* %i to i32 addrspace(4)*
// CHECK: %i.ascast = addrspacecast i32* %i to i32 addrspace(4)*
// CHECK: %[[ARR:[a-zA-Z0-9]+]] = alloca [42 x i32]

int i = 0;
int *pptr = &i;
// CHECK-LEGACY: store i32* %i, i32** %pptr
// CHECK-NEW: %[[GEN:[0-9]+]] = addrspacecast i32* %i to i32 addrspace(4)*
// CHECK-NEW: store i32 addrspace(4)* %[[GEN]], i32 addrspace(4)** %pptr
// CHECK: %[[GEN:[0-9]+]] = addrspacecast i32* %i to i32 addrspace(4)*
// CHECK: store i32 addrspace(4)* %[[GEN]], i32 addrspace(4)** %pptr
bool is_i_ptr = (pptr == &i);
// CHECK-LEGACY: %[[VALPPTR:[0-9]+]] = load i32*, i32** %pptr
// CHECK-LEGACY: %cmp{{[0-9]*}} = icmp eq i32* %[[VALPPTR]], %i
// CHECK-NEW: %[[VALPPTR:[0-9]+]] = load i32 addrspace(4)*, i32 addrspace(4)** %pptr
// CHECK-NEW: %cmp{{[0-9]*}} = icmp eq i32 addrspace(4)* %[[VALPPTR]], %i.ascast
// CHECK: %[[VALPPTR:[0-9]+]] = load i32 addrspace(4)*, i32 addrspace(4)** %pptr
// CHECK: %cmp{{[0-9]*}} = icmp eq i32 addrspace(4)* %[[VALPPTR]], %i.ascast
*pptr = foo;

int var23 = 23;
char *cp = (char *)&var23;
*cp = 41;
// CHECK: store i32 23, i32* %[[VAR:[a-zA-Z0-9]+]]
// CHECK-LEGACY: [[VARCAST:[a-zA-Z0-9]+]] = bitcast i32* %[[VAR]] to i8*
// CHECK-LEGACY: store i8* %[[VARCAST]], i8** %{{.*}}
// CHECK-NEW: [[VARAS:[a-zA-Z0-9]+]] = addrspacecast i32* %[[VAR]] to i32 addrspace(4)*
// CHECK-NEW: [[VARCAST:[a-zA-Z0-9]+]] = bitcast i32 addrspace(4)* %[[VARAS]] to i8 addrspace(4)*
// CHECK-NEW: store i8 addrspace(4)* %[[VARCAST]], i8 addrspace(4)** %{{.*}}
// CHECK: [[VARAS:[a-zA-Z0-9]+]] = addrspacecast i32* %[[VAR]] to i32 addrspace(4)*
// CHECK: [[VARCAST:[a-zA-Z0-9]+]] = bitcast i32 addrspace(4)* %[[VARAS]] to i8 addrspace(4)*
// CHECK: store i8 addrspace(4)* %[[VARCAST]], i8 addrspace(4)** %{{.*}}

int arr[42];
char *cpp = (char *)arr;
*cpp = 43;
// CHECK: %[[ARRDECAY:[a-zA-Z0-9]+]] = getelementptr inbounds [42 x i32], [42 x i32]* %[[ARR]], i64 0, i64 0
// CHECK-LEGACY: [[ARRCAST:[a-zA-Z0-9]+]] = bitcast i32* %[[ARRDECAY]] to i8*
// CHECK-LEGACY: store i8* %[[ARRCAST]], i8** %{{.*}}
// CHECK-NEW: %[[ARRAS:[a-zA-Z0-9]+]] = addrspacecast i32* %[[ARRDECAY]] to i32 addrspace(4)*
// CHECK-NEW: %[[ARRCAST:[a-zA-Z0-9]+]] = bitcast i32 addrspace(4)* %[[ARRAS]] to i8 addrspace(4)*
// CHECK-NEW: store i8 addrspace(4)* %[[ARRCAST]], i8 addrspace(4)** %{{.*}}
// CHECK: %[[ARRAS:[a-zA-Z0-9]+]] = addrspacecast i32* %[[ARRDECAY]] to i32 addrspace(4)*
// CHECK: %[[ARRCAST:[a-zA-Z0-9]+]] = bitcast i32 addrspace(4)* %[[ARRAS]] to i8 addrspace(4)*
// CHECK: store i8 addrspace(4)* %[[ARRCAST]], i8 addrspace(4)** %{{.*}}

int *aptr = arr + 10;
if (aptr < arr + sizeof(arr))
*aptr = 44;
// CHECK-LEGACY: %[[VALAPTR:[0-9]+]] = load i32*, i32** %aptr
// CHECK-NEW: %[[VALAPTR:[0-9]+]] = load i32 addrspace(4)*, i32 addrspace(4)** %aptr
// CHECK: %[[VALAPTR:[0-9]+]] = load i32 addrspace(4)*, i32 addrspace(4)** %aptr
// CHECK: %[[ARRDCY2:[a-zA-Z0-9]+]] = getelementptr inbounds [42 x i32], [42 x i32]* %[[ARR]], i64 0, i64 0
// CHECK: %[[ADDPTR:[a-zA-Z0-9.]+]] = getelementptr inbounds i32, i32* %[[ARRDCY2]], i64 168
// CHECK-LEGACY: %cmp{{[0-9]+}} = icmp ult i32* %[[VALAPTR]], %[[ADDPTR]]
// CHECK-NEW: %[[ADDPTRCAST:[a-zA-Z0-9.]+]] = addrspacecast i32* %[[ADDPTR]] to i32 addrspace(4)*
// CHECK-NEW: %cmp{{[0-9]+}} = icmp ult i32 addrspace(4)* %[[VALAPTR]], %[[ADDPTRCAST]]
// CHECK: %[[ADDPTRCAST:[a-zA-Z0-9.]+]] = addrspacecast i32* %[[ADDPTR]] to i32 addrspace(4)*
// CHECK: %cmp{{[0-9]+}} = icmp ult i32 addrspace(4)* %[[VALAPTR]], %[[ADDPTRCAST]]

const char *str = "Hello, world!";
// CHECK-LEGACY: store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @[[STR]], i64 0, i64 0), i8** %[[STRVAL:[a-zA-Z0-9]+]], align 8
// CHECK-NEW: store i8 addrspace(4)* addrspacecast (i8* getelementptr inbounds ([14 x i8], [14 x i8]* @[[STR]], i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)** %[[STRVAL:[a-zA-Z0-9]+]], align 8
// CHECK: store i8 addrspace(4)* addrspacecast (i8* getelementptr inbounds ([14 x i8], [14 x i8]* @[[STR]], i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)** %[[STRVAL:[a-zA-Z0-9]+]], align 8

i = str[0];

Expand All @@ -92,48 +79,35 @@ void test() {
// CHECK: br i1 %[[COND]], label %[[CONDTRUE:[.a-zA-Z0-9]+]], label %[[CONDFALSE:[.a-zA-Z0-9]+]]

// CHECK: [[CONDTRUE]]:
// CHECK-LEGACY-NEXT: %[[VALTRUE:[a-zA-Z0-9]+]] = load i8*, i8** %[[STRVAL]]
// CHECK-LEGACY-NEXT: br label %[[CONDEND:[.a-zA-Z0-9]+]]
// CHECK-NEW-NEXT: %[[VALTRUE:[a-zA-Z0-9]+]] = load i8 addrspace(4)*, i8 addrspace(4)** %[[STRVAL]]
// CHECK-NEW-NEXT: br label %[[CONDEND:[.a-zA-Z0-9]+]]
// CHECK-NEXT: %[[VALTRUE:[a-zA-Z0-9]+]] = load i8 addrspace(4)*, i8 addrspace(4)** %[[STRVAL]]
// CHECK-NEXT: br label %[[CONDEND:[.a-zA-Z0-9]+]]

// CHECK: [[CONDFALSE]]:
// CHECK-LEGACY-NEXT: br label %[[CONDEND]]

// CHECK-LEGACY: [[CONDEND]]:
// CHECK-NEW: [[CONDEND]]:
// CHECK-NEW-NEXT: phi i8 addrspace(4)* [ %[[VALTRUE]], %[[CONDTRUE]] ], [ addrspacecast (i8* getelementptr inbounds ([21 x i8], [21 x i8]* @{{.*}}, i64 0, i64 0) to i8 addrspace(4)*), %[[CONDFALSE]] ]
// CHECK-LEGACY-NEXT: phi i8* [ %[[VALTRUE]], %[[CONDTRUE]] ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @{{.*}}, i64 0, i64 0), %[[CONDFALSE]] ]
// CHECK: [[CONDEND]]:
// CHECK-NEXT: phi i8 addrspace(4)* [ %[[VALTRUE]], %[[CONDTRUE]] ], [ addrspacecast (i8* getelementptr inbounds ([21 x i8], [21 x i8]* @{{.*}}, i64 0, i64 0) to i8 addrspace(4)*), %[[CONDFALSE]] ]

const char *select_null = i > 2 ? "Yet another Hello world" : nullptr;
(void)select_null;
// CHECK-LEGACY: select i1 %{{.*}}, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @{{.*}}, i64 0, i64 0), i8* null
// CHECK-NEW: select i1 %{{.*}}, i8 addrspace(4)* addrspacecast (i8* getelementptr inbounds ([24 x i8], [24 x i8]* @{{.*}}, i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)* null
// CHECK: select i1 %{{.*}}, i8 addrspace(4)* addrspacecast (i8* getelementptr inbounds ([24 x i8], [24 x i8]* @{{.*}}, i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)* null

const char *select_str_trivial1 = true ? str : "Another hello world!";
(void)select_str_trivial1;
// CHECK-LEGACY: %[[TRIVIALTRUE:[a-zA-Z0-9]+]] = load i8*, i8** %[[STRVAL]]
// CHECK-LEGACY: store i8* %[[TRIVIALTRUE]], i8** %{{.*}}, align 8
// CHECK-NEW: %[[TRIVIALTRUE:[a-zA-Z0-9]+]] = load i8 addrspace(4)*, i8 addrspace(4)** %[[STRVAL]]
// CHECK-NEW: store i8 addrspace(4)* %[[TRIVIALTRUE]], i8 addrspace(4)** %{{.*}}, align 8
// CHECK: %[[TRIVIALTRUE:[a-zA-Z0-9]+]] = load i8 addrspace(4)*, i8 addrspace(4)** %[[STRVAL]]
// CHECK: store i8 addrspace(4)* %[[TRIVIALTRUE]], i8 addrspace(4)** %{{.*}}, align 8

const char *select_str_trivial2 = false ? str : "Another hello world!";
(void)select_str_trivial2;
// CHECK-LEGACY: store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @{{.*}}, i64 0, i64 0), i8** %{{.*}}
// CHECK-NEW: store i8 addrspace(4)* addrspacecast (i8* getelementptr inbounds ([21 x i8], [21 x i8]* @{{.*}}, i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)** %{{.*}}
// CHECK: store i8 addrspace(4)* addrspacecast (i8* getelementptr inbounds ([21 x i8], [21 x i8]* @{{.*}}, i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)** %{{.*}}
//
//
Y yy;
baz(yy);
// CHECK: define spir_func void @{{.*}}baz{{.*}}
// CHECK-LEGACY: %[[FIRST:[a-zA-Z0-9]+]] = bitcast %struct.{{.*}}.Y* %{{.*}} to i8*
// CHECK-LEGACY: %[[OFFSET:[a-zA-Z0-9]+]].ptr = getelementptr inbounds i8, i8* %[[FIRST]], i64 8
// CHECK-LEGACY: %[[SECOND:[a-zA-Z0-9]+]] = bitcast i8* %[[OFFSET]].ptr to %struct.{{.*}}.HasX*
// CHECK-LEGACY: call spir_func void @{{.*}}bar{{.*}}(%struct.{{.*}}.HasX* dereferenceable(4) %[[SECOND]])
// CHECK-NEW: %[[FIRST:[a-zA-Z0-9]+]] = bitcast %struct.{{.*}}.Y addrspace(4)* %{{.*}} to i8 addrspace(4)*
// CHECK-NEW: %[[OFFSET:[a-zA-Z0-9]+]].ptr = getelementptr inbounds i8, i8 addrspace(4)* %[[FIRST]], i64 8
// CHECK-NEW: %[[SECOND:[a-zA-Z0-9]+]] = bitcast i8 addrspace(4)* %[[OFFSET]].ptr to %struct.{{.*}}.HasX addrspace(4)*
// CHECK-NEW: call spir_func void @{{.*}}bar{{.*}}(%struct.{{.*}}.HasX addrspace(4)* dereferenceable(4) %[[SECOND]])
// CHECK: %[[FIRST:[a-zA-Z0-9]+]] = bitcast %struct.{{.*}}.Y addrspace(4)* %{{.*}} to i8 addrspace(4)*
// CHECK: %[[OFFSET:[a-zA-Z0-9]+]].ptr = getelementptr inbounds i8, i8 addrspace(4)* %[[FIRST]], i64 8
// CHECK: %[[SECOND:[a-zA-Z0-9]+]] = bitcast i8 addrspace(4)* %[[OFFSET]].ptr to %struct.{{.*}}.HasX addrspace(4)*
// CHECK: call spir_func void @{{.*}}bar{{.*}}(%struct.{{.*}}.HasX addrspace(4)* dereferenceable(4) %[[SECOND]])
}


Expand All @@ -147,6 +121,3 @@ int main() {
kernel_single_task<class fake_kernel>([]() { test(); });
return 0;
}

// TODO: SYCL specific fail - analyze and enable
// XFAIL: windows-msvc
Loading