-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang][OpenCL][CodeGen][AMDGPU] Do not use private as the default AS for when generic is available
#112442
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
[clang][OpenCL][CodeGen][AMDGPU] Do not use private as the default AS for when generic is available
#112442
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ca91962
`private` is a terrible default AS, and is terrible and wrong for OCL…
AlexVlx a742e92
Fix formatting.
AlexVlx 2b2c236
Merge branch 'main' of https://github.com/llvm/llvm-project into priv…
AlexVlx 667fd20
Merge branch 'main' of https://github.com/llvm/llvm-project into priv…
AlexVlx 7fcb506
Strip less.
AlexVlx 5696c42
Merge branch 'main' of https://github.com/llvm/llvm-project into priv…
AlexVlx c4e603d
Fix borked merge.
AlexVlx e7fdefd
Update tests.
AlexVlx 428fdd2
Merge branch 'main' of https://github.com/llvm/llvm-project into priv…
AlexVlx 988a1b8
Fix mangled test.
AlexVlx 85bba76
Re-add missing `CHECK`.
AlexVlx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
1,521 changes: 1,440 additions & 81 deletions
1,521
clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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,67 +1,111 @@ | ||
| // RUN: %clang_cc1 -O0 -cl-std=CL1.2 -triple amdgcn---amdgizcl -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL12 %s | ||
| // RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn---amdgizcl -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL20 %s | ||
| // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 | ||
| // RUN: %clang_cc1 -O0 -cl-std=CL1.2 -triple amdgcn---amdgizcl -emit-llvm %s -o - | FileCheck -check-prefixes=CL12 %s | ||
AlexVlx marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn---amdgizcl -emit-llvm %s -o - | FileCheck -check-prefixes=CL20 %s | ||
|
|
||
| // CL12-LABEL: define{{.*}} void @func1(ptr addrspace(5) noundef %x) | ||
| // CL20-LABEL: define{{.*}} void @func1(ptr noundef %x) | ||
| // CL12-LABEL: define dso_local void @func1( | ||
| // CL12-SAME: ptr addrspace(5) noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] { | ||
| // CL12-NEXT: [[ENTRY:.*:]] | ||
| // CL12-NEXT: [[X_ADDR:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5) | ||
| // CL12-NEXT: store ptr addrspace(5) [[X]], ptr addrspace(5) [[X_ADDR]], align 4 | ||
| // CL12-NEXT: [[TMP0:%.*]] = load ptr addrspace(5), ptr addrspace(5) [[X_ADDR]], align 4 | ||
| // CL12-NEXT: store i32 1, ptr addrspace(5) [[TMP0]], align 4 | ||
| // CL12-NEXT: ret void | ||
| // | ||
| // CL20-LABEL: define dso_local void @func1( | ||
| // CL20-SAME: ptr noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] { | ||
| // CL20-NEXT: [[ENTRY:.*:]] | ||
| // CL20-NEXT: [[X_ADDR:%.*]] = alloca ptr, align 8, addrspace(5) | ||
| // CL20-NEXT: [[X_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[X_ADDR]] to ptr | ||
| // CL20-NEXT: store ptr [[X]], ptr [[X_ADDR_ASCAST]], align 8 | ||
| // CL20-NEXT: [[TMP0:%.*]] = load ptr, ptr [[X_ADDR_ASCAST]], align 8 | ||
| // CL20-NEXT: store i32 1, ptr [[TMP0]], align 4 | ||
| // CL20-NEXT: ret void | ||
| // | ||
| void func1(int *x) { | ||
| // CL12: %[[x_addr:.*]] = alloca ptr addrspace(5){{.*}}addrspace(5) | ||
| // CL12: store ptr addrspace(5) %x, ptr addrspace(5) %[[x_addr]] | ||
| // CL12: %[[r0:.*]] = load ptr addrspace(5), ptr addrspace(5) %[[x_addr]] | ||
| // CL12: store i32 1, ptr addrspace(5) %[[r0]] | ||
| // CL20: %[[x_addr:.*]] = alloca ptr{{.*}}addrspace(5) | ||
| // CL20: store ptr %x, ptr addrspace(5) %[[x_addr]] | ||
| // CL20: %[[r0:.*]] = load ptr, ptr addrspace(5) %[[x_addr]] | ||
| // CL20: store i32 1, ptr %[[r0]] | ||
| *x = 1; | ||
| } | ||
|
|
||
| // CHECK-LABEL: define{{.*}} void @func2() | ||
| // CL12-LABEL: define dso_local void @func2( | ||
| // CL12-SAME: ) #[[ATTR0]] { | ||
| // CL12-NEXT: [[ENTRY:.*:]] | ||
| // CL12-NEXT: [[LV1:%.*]] = alloca i32, align 4, addrspace(5) | ||
| // CL12-NEXT: [[LV2:%.*]] = alloca i32, align 4, addrspace(5) | ||
| // CL12-NEXT: [[LA:%.*]] = alloca [100 x i32], align 4, addrspace(5) | ||
| // CL12-NEXT: [[LP1:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5) | ||
| // CL12-NEXT: [[LP2:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5) | ||
| // CL12-NEXT: [[LVC:%.*]] = alloca i32, align 4, addrspace(5) | ||
| // CL12-NEXT: store i32 1, ptr addrspace(5) [[LV1]], align 4 | ||
| // CL12-NEXT: store i32 2, ptr addrspace(5) [[LV2]], align 4 | ||
| // CL12-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [100 x i32], ptr addrspace(5) [[LA]], i64 0, i64 0 | ||
| // CL12-NEXT: store i32 3, ptr addrspace(5) [[ARRAYIDX]], align 4 | ||
| // CL12-NEXT: store ptr addrspace(5) [[LV1]], ptr addrspace(5) [[LP1]], align 4 | ||
| // CL12-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [100 x i32], ptr addrspace(5) [[LA]], i64 0, i64 0 | ||
| // CL12-NEXT: store ptr addrspace(5) [[ARRAYDECAY]], ptr addrspace(5) [[LP2]], align 4 | ||
| // CL12-NEXT: call void @func1(ptr addrspace(5) noundef [[LV1]]) #[[ATTR2:[0-9]+]] | ||
| // CL12-NEXT: store i32 4, ptr addrspace(5) [[LVC]], align 4 | ||
| // CL12-NEXT: store i32 4, ptr addrspace(5) [[LV1]], align 4 | ||
| // CL12-NEXT: ret void | ||
| // | ||
| // CL20-LABEL: define dso_local void @func2( | ||
| // CL20-SAME: ) #[[ATTR0]] { | ||
| // CL20-NEXT: [[ENTRY:.*:]] | ||
| // CL20-NEXT: [[LV1:%.*]] = alloca i32, align 4, addrspace(5) | ||
| // CL20-NEXT: [[LV2:%.*]] = alloca i32, align 4, addrspace(5) | ||
| // CL20-NEXT: [[LA:%.*]] = alloca [100 x i32], align 4, addrspace(5) | ||
| // CL20-NEXT: [[LP1:%.*]] = alloca ptr, align 8, addrspace(5) | ||
| // CL20-NEXT: [[LP2:%.*]] = alloca ptr, align 8, addrspace(5) | ||
| // CL20-NEXT: [[LVC:%.*]] = alloca i32, align 4, addrspace(5) | ||
| // CL20-NEXT: [[LV1_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[LV1]] to ptr | ||
| // CL20-NEXT: [[LV2_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[LV2]] to ptr | ||
| // CL20-NEXT: [[LA_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[LA]] to ptr | ||
| // CL20-NEXT: [[LP1_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[LP1]] to ptr | ||
| // CL20-NEXT: [[LP2_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[LP2]] to ptr | ||
| // CL20-NEXT: [[LVC_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[LVC]] to ptr | ||
| // CL20-NEXT: store i32 1, ptr [[LV1_ASCAST]], align 4 | ||
| // CL20-NEXT: store i32 2, ptr [[LV2_ASCAST]], align 4 | ||
| // CL20-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [100 x i32], ptr [[LA_ASCAST]], i64 0, i64 0 | ||
| // CL20-NEXT: store i32 3, ptr [[ARRAYIDX]], align 4 | ||
| // CL20-NEXT: store ptr [[LV1_ASCAST]], ptr [[LP1_ASCAST]], align 8 | ||
| // CL20-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [100 x i32], ptr [[LA_ASCAST]], i64 0, i64 0 | ||
| // CL20-NEXT: store ptr [[ARRAYDECAY]], ptr [[LP2_ASCAST]], align 8 | ||
| // CL20-NEXT: call void @func1(ptr noundef [[LV1_ASCAST]]) #[[ATTR2:[0-9]+]] | ||
| // CL20-NEXT: store i32 4, ptr [[LVC_ASCAST]], align 4 | ||
| // CL20-NEXT: store i32 4, ptr [[LV1_ASCAST]], align 4 | ||
| // CL20-NEXT: ret void | ||
| // | ||
| void func2(void) { | ||
| // CHECK: %lv1 = alloca i32, align 4, addrspace(5) | ||
| // CHECK: %lv2 = alloca i32, align 4, addrspace(5) | ||
| // CHECK: %la = alloca [100 x i32], align 4, addrspace(5) | ||
| // CL12: %lp1 = alloca ptr addrspace(5), align 4, addrspace(5) | ||
| // CL12: %lp2 = alloca ptr addrspace(5), align 4, addrspace(5) | ||
| // CL20: %lp1 = alloca ptr, align 8, addrspace(5) | ||
| // CL20: %lp2 = alloca ptr, align 8, addrspace(5) | ||
| // CHECK: %lvc = alloca i32, align 4, addrspace(5) | ||
|
|
||
| // CHECK: store i32 1, ptr addrspace(5) %lv1 | ||
| int lv1; | ||
| lv1 = 1; | ||
| // CHECK: store i32 2, ptr addrspace(5) %lv2 | ||
| int lv2 = 2; | ||
|
|
||
| // CHECK: %[[arrayidx:.*]] = getelementptr inbounds [100 x i32], ptr addrspace(5) %la, i64 0, i64 0 | ||
| // CHECK: store i32 3, ptr addrspace(5) %[[arrayidx]], align 4 | ||
| int la[100]; | ||
| la[0] = 3; | ||
|
|
||
| // CL12: store ptr addrspace(5) %lv1, ptr addrspace(5) %lp1, align 4 | ||
| // CL20: %[[r0:.*]] = addrspacecast ptr addrspace(5) %lv1 to ptr | ||
| // CL20: store ptr %[[r0]], ptr addrspace(5) %lp1, align 8 | ||
| int *lp1 = &lv1; | ||
|
|
||
| // CHECK: %[[arraydecay:.*]] = getelementptr inbounds [100 x i32], ptr addrspace(5) %la, i64 0, i64 0 | ||
| // CL12: store ptr addrspace(5) %[[arraydecay]], ptr addrspace(5) %lp2, align 4 | ||
| // CL20: %[[r1:.*]] = addrspacecast ptr addrspace(5) %[[arraydecay]] to ptr | ||
| // CL20: store ptr %[[r1]], ptr addrspace(5) %lp2, align 8 | ||
| int *lp2 = la; | ||
|
|
||
| // CL12: call void @func1(ptr addrspace(5) noundef %lv1) | ||
| // CL20: %[[r2:.*]] = addrspacecast ptr addrspace(5) %lv1 to ptr | ||
| // CL20: call void @func1(ptr noundef %[[r2]]) | ||
| func1(&lv1); | ||
|
|
||
| // CHECK: store i32 4, ptr addrspace(5) %lvc | ||
| // CHECK: store i32 4, ptr addrspace(5) %lv1 | ||
| const int lvc = 4; | ||
| lv1 = lvc; | ||
| } | ||
|
|
||
| // CHECK-LABEL: define{{.*}} void @func3() | ||
| // CHECK: %a = alloca [16 x [1 x float]], align 4, addrspace(5) | ||
| // CHECK: call void @llvm.memset.p5.i64(ptr addrspace(5) align 4 %a, i8 0, i64 64, i1 false) | ||
| // CL12-LABEL: define dso_local void @func3( | ||
| // CL12-SAME: ) #[[ATTR0]] { | ||
| // CL12-NEXT: [[ENTRY:.*:]] | ||
| // CL12-NEXT: [[A:%.*]] = alloca [16 x [1 x float]], align 4, addrspace(5) | ||
| // CL12-NEXT: call void @llvm.memset.p5.i64(ptr addrspace(5) align 4 [[A]], i8 0, i64 64, i1 false) | ||
| // CL12-NEXT: ret void | ||
| // | ||
| // CL20-LABEL: define dso_local void @func3( | ||
| // CL20-SAME: ) #[[ATTR0]] { | ||
| // CL20-NEXT: [[ENTRY:.*:]] | ||
| // CL20-NEXT: [[A:%.*]] = alloca [16 x [1 x float]], align 4, addrspace(5) | ||
| // CL20-NEXT: [[A_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[A]] to ptr | ||
| // CL20-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[A_ASCAST]], i8 0, i64 64, i1 false) | ||
| // CL20-NEXT: ret void | ||
| // | ||
| void func3(void) { | ||
| float a[16][1] = {{0.}}; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would hope alloc would be the direct alloca reference to begin with