forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Fix addressspace cast for _alloca (intel#6087)
This is a follow-up to PR#6050. The cast should use element type and not change type. PR#6050 incorrectly change Type* to Type** (when adding the cast) This patch also add opaque pointer version of the test. Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
- Loading branch information
1 parent
082929a
commit 5512425
Showing
3 changed files
with
27 additions
and
8 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 |
---|---|---|
@@ -1,13 +1,12 @@ | ||
// RUN: %clang_cc1 -triple spir64-unknown-linux -fsycl-is-device -disable-llvm-passes -emit-llvm -x c++ %s -o - | FileCheck %s | ||
// RUN: %clang_cc1 -triple spir64-unknown-linux -fsycl-is-device -disable-llvm-passes -opaque-pointers -emit-llvm -x c++ %s -o - | FileCheck %s | ||
|
||
// Test to verify that address space cast is generated correctly for __builtin_alloca | ||
|
||
__attribute__((sycl_device)) void foo() { | ||
// CHECK: %TestVar = alloca i32 addrspace(4)*, align 8 | ||
// CHECK: %TestVar.ascast = addrspacecast i32 addrspace(4)** %TestVar to i32 addrspace(4)* addrspace(4)* | ||
// CHECK: %TestVar = alloca ptr addrspace(4), align 8 | ||
// CHECK: %TestVar.ascast = addrspacecast ptr %TestVar to ptr addrspace(4) | ||
// CHECK: %[[ALLOCA:[0-9]+]] = alloca i8, i64 1, align 8 | ||
// CHECK: %[[ADDRSPCAST:[0-9]+]] = addrspacecast i8* %[[ALLOCA]] to i8* addrspace(4)* | ||
// CHECK: %[[BITCAST:[0-9]+]] = bitcast i8* addrspace(4)* %[[ADDRSPCAST]] to i32 addrspace(4)* | ||
// CHECK: store i32 addrspace(4)* %[[BITCAST]], i32 addrspace(4)* addrspace(4)* %TestVar.ascast, align 8 | ||
// CHECK: %[[ADDRSPCAST:[0-9]+]] = addrspacecast ptr %[[ALLOCA]] to ptr addrspace(4) | ||
// CHECK: store ptr addrspace(4) %[[ADDRSPCAST]], ptr addrspace(4) %TestVar.ascast, align 8 | ||
int *TestVar = (int *)__builtin_alloca(1); | ||
} |
13 changes: 13 additions & 0 deletions
13
clang/test/CodeGenSYCL/no_opaque_address-space-builtin-alloca.cpp
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,13 @@ | ||
// RUN: %clang_cc1 -triple spir64-unknown-linux -fsycl-is-device -disable-llvm-passes -no-opaque-pointers -emit-llvm -x c++ %s -o - | FileCheck %s | ||
|
||
// Test to verify that address space cast is generated correctly for __builtin_alloca | ||
|
||
__attribute__((sycl_device)) void foo() { | ||
// CHECK: %TestVar = alloca i32 addrspace(4)*, align 8 | ||
// CHECK: %TestVar.ascast = addrspacecast i32 addrspace(4)** %TestVar to i32 addrspace(4)* addrspace(4)* | ||
// CHECK: %[[ALLOCA:[0-9]+]] = alloca i8, i64 1, align 8 | ||
// CHECK: %[[ADDRSPCAST:[0-9]+]] = addrspacecast i8* %[[ALLOCA]] to i8 addrspace(4)* | ||
// CHECK: %[[BITCAST:[0-9]+]] = bitcast i8 addrspace(4)* %[[ADDRSPCAST]] to i32 addrspace(4)* | ||
// CHECK: store i32 addrspace(4)* %[[BITCAST]], i32 addrspace(4)* addrspace(4)* %TestVar.ascast, align 8 | ||
int *TestVar = (int *)__builtin_alloca(1); | ||
} |