-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[OpenMP] Don't emit redundant zero-sized mapping nodes for overlapped structs #148947
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
Open
jtb20
wants to merge
1
commit into
llvm:main
Choose a base branch
from
jtb20:empty-mappings-overlapped-data-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp-targets=amdgcn-amd-amdhsa -fopenmp -emit-llvm %s -o - | FileCheck %s | ||
// expected-no-diagnostics | ||
|
||
struct S { | ||
int x; | ||
int y; | ||
int z; | ||
int *p1; | ||
int *p2; | ||
}; | ||
|
||
struct T : public S { | ||
int a; | ||
int b; | ||
int c; | ||
}; | ||
|
||
int main() { | ||
T v; | ||
|
||
#pragma omp target map(tofrom: v, v.x, v.y, v.z, v.p1[:8], v.a, v.b, v.c) | ||
{ | ||
v.x++; | ||
v.y += 2; | ||
v.z += 3; | ||
v.p1[0] += 4; | ||
v.a += 7; | ||
v.b += 5; | ||
v.c += 6; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
// CHECK: [[CSTSZ:@.+]] = private {{.*}}constant [10 x i64] [i64 0, i64 0, i64 0, i64 4, i64 4, i64 4, i64 32, i64 4, i64 4, i64 4] | ||
// CHECK: [[CSTTY:@.+]] = private {{.*}}constant [10 x i64] [i64 [[#0x20]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]], i64 [[#0x1000000000013]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]]] | ||
|
||
// CHECK-DAG: call i32 @__tgt_target_kernel(ptr @{{.+}}, i64 -1, i32 -1, i32 0, ptr @.{{.+}}.region_id, ptr [[ARGS:%.+]]) | ||
// CHECK-DAG: [[KSIZE:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 4 | ||
// CHECK-DAG: store ptr [[SZBASE:%.+]], ptr [[KSIZE]], align 8 | ||
// CHECK-DAG: [[SZBASE]] = getelementptr inbounds [10 x i64], ptr [[SIZES:%[^,]*]], i32 0, i32 0 | ||
|
||
// Check for filling of four non-constant size elements here: the whole struct | ||
// size, the (padded) region covering p1 & p2, and the padding at the end of | ||
// struct T. | ||
|
||
// CHECK-DAG: [[STR:%.+]] = getelementptr inbounds [10 x i64], ptr [[SIZES]], i32 0, i32 0 | ||
// CHECK-DAG: store i64 %{{.+}}, ptr [[STR]], align 8 | ||
// CHECK-DAG: [[P1P2:%.+]] = getelementptr inbounds [10 x i64], ptr [[SIZES]], i32 0, i32 1 | ||
// CHECK-DAG: store i64 %{{.+}}, ptr [[P1P2]], align 8 | ||
// CHECK-DAG: [[PAD:%.+]] = getelementptr inbounds [10 x i64], ptr [[SIZES]], i32 0, i32 2 | ||
// CHECK-DAG: store i64 %{{.+}}, ptr [[PAD]], align 8 |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp-targets=amdgcn-amd-amdhsa -fopenmp -emit-llvm %s -o - | FileCheck %s | ||
// expected-no-diagnostics | ||
|
||
struct S { | ||
int x; | ||
int y; | ||
int z; | ||
}; | ||
|
||
struct M : public S { | ||
int mid; | ||
}; | ||
|
||
struct T : public M { | ||
int a; | ||
int b; | ||
int c; | ||
}; | ||
|
||
int main() { | ||
T v; | ||
|
||
#pragma omp target map(tofrom: v, v.y, v.z, v.a) | ||
{ | ||
v.y++; | ||
v.z += 2; | ||
v.a += 3; | ||
v.mid += 5; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
// CHECK: [[CSTSZ:@.+]] = private {{.*}}constant [7 x i64] [i64 0, i64 0, i64 0, i64 0, i64 4, i64 4, i64 4] | ||
// CHECK: [[CSTTY:@.+]] = private {{.*}}constant [7 x i64] [i64 [[#0x20]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]]] | ||
|
||
// CHECK-DAG: call i32 @__tgt_target_kernel(ptr @{{.+}}, i64 -1, i32 -1, i32 0, ptr @.{{.+}}.region_id, ptr [[ARGS:%.+]]) | ||
// CHECK-DAG: [[KSIZE:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 4 | ||
// CHECK-DAG: store ptr [[SZBASE:%.+]], ptr [[KSIZE]], align 8 | ||
// CHECK-DAG: [[SZBASE]] = getelementptr inbounds [7 x i64], ptr [[SIZES:%[^,]*]], i32 0, i32 0 | ||
|
||
// Fill four non-constant size elements here: the whole struct size, the region | ||
// covering v.x, the region covering v.mid and the region covering v.b and v.c. | ||
|
||
// CHECK-DAG: [[STR:%.+]] = getelementptr inbounds [7 x i64], ptr [[SIZES]], i32 0, i32 0 | ||
// CHECK-DAG: store i64 %{{.+}}, ptr [[STR]], align 8 | ||
// CHECK-DAG: [[X:%.+]] = getelementptr inbounds [7 x i64], ptr [[SIZES]], i32 0, i32 1 | ||
// CHECK-DAG: store i64 %{{.+}}, ptr [[X]], align 8 | ||
// CHECK-DAG: [[MID:%.+]] = getelementptr inbounds [7 x i64], ptr [[SIZES]], i32 0, i32 2 | ||
// CHECK-DAG: store i64 %{{.+}}, ptr [[MID]], align 8 | ||
// CHECK-DAG: [[BC:%.+]] = getelementptr inbounds [7 x i64], ptr [[SIZES]], i32 0, i32 3 | ||
// CHECK-DAG: store i64 %{{.+}}, ptr [[BC]], align 8 |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp-targets=amdgcn-amd-amdhsa -fopenmp -emit-llvm %s -o - | FileCheck %s | ||
// expected-no-diagnostics | ||
|
||
struct S { | ||
int x; | ||
int y; | ||
int z; | ||
}; | ||
|
||
struct T : public S { | ||
int a; | ||
int b; | ||
int c; | ||
}; | ||
|
||
int main() { | ||
T v; | ||
|
||
// This one should have no gap between v.z & v.a. | ||
#pragma omp target map(tofrom: v, v.y, v.z, v.a) | ||
{ | ||
v.y++; | ||
v.z += 2; | ||
v.a += 3; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
// CHECK: [[CSTSZ:@.+]] = private {{.*}}constant [6 x i64] [i64 0, i64 0, i64 0, i64 4, i64 4, i64 4] | ||
// CHECK: [[CSTTY:@.+]] = private {{.*}}constant [6 x i64] [i64 [[#0x20]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]]] | ||
|
||
// CHECK-DAG: call i32 @__tgt_target_kernel(ptr @{{.+}}, i64 -1, i32 -1, i32 0, ptr @.{{.+}}.region_id, ptr [[ARGS:%.+]]) | ||
// CHECK-DAG: [[KSIZE:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 4 | ||
// CHECK-DAG: store ptr [[SZBASE:%.+]], ptr [[KSIZE]], align 8 | ||
// CHECK-DAG: [[SZBASE]] = getelementptr inbounds [6 x i64], ptr [[SIZES:%[^,]*]], i32 0, i32 0 | ||
|
||
// Fill three non-constant size elements here: the whole struct size, the region | ||
// covering v.x, and the region covering v.b and v.c. | ||
|
||
// CHECK-DAG: [[STR:%.+]] = getelementptr inbounds [6 x i64], ptr [[SIZES]], i32 0, i32 0 | ||
// CHECK-DAG: store i64 %{{.+}}, ptr [[STR]], align 8 | ||
// CHECK-DAG: [[X:%.+]] = getelementptr inbounds [6 x i64], ptr [[SIZES]], i32 0, i32 1 | ||
// CHECK-DAG: store i64 %{{.+}}, ptr [[X]], align 8 | ||
// CHECK-DAG: [[BC:%.+]] = getelementptr inbounds [6 x i64], ptr [[SIZES]], i32 0, i32 2 | ||
// CHECK-DAG: store i64 %{{.+}}, ptr [[BC]], align 8 |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp-targets=amdgcn-amd-amdhsa -fopenmp -emit-llvm %s -o - | FileCheck %s | ||
// expected-no-diagnostics | ||
|
||
struct S { | ||
int x; | ||
int y; | ||
char z; // Hidden padding after here... | ||
}; | ||
|
||
struct T : public S { | ||
int a; | ||
int b; | ||
int c; | ||
}; | ||
|
||
int main() { | ||
T v; | ||
|
||
#pragma omp target map(tofrom: v, v.y, v.z, v.a) | ||
{ | ||
v.y++; | ||
v.z += 2; | ||
v.a += 3; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
// CHECK: [[CSTSZ:@.+]] = private {{.*}}constant [7 x i64] [i64 0, i64 0, i64 0, i64 0, i64 4, i64 1, i64 4] | ||
// CHECK: [[CSTTY:@.+]] = private {{.*}}constant [7 x i64] [i64 [[#0x20]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]], i64 [[#0x1000000000003]]] | ||
|
||
// CHECK-DAG: call i32 @__tgt_target_kernel(ptr @{{.+}}, i64 -1, i32 -1, i32 0, ptr @.{{.+}}.region_id, ptr [[ARGS:%.+]]) | ||
// CHECK-DAG: [[KSIZE:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 4 | ||
// CHECK-DAG: store ptr [[SZBASE:%.+]], ptr [[KSIZE]], align 8 | ||
// CHECK-DAG: [[SZBASE]] = getelementptr inbounds [7 x i64], ptr [[SIZES:%[^,]*]], i32 0, i32 0 | ||
|
||
// Fill four non-constant size elements here: the whole struct size, the region | ||
// covering v.x, the region covering padding after v.z and the region covering | ||
// v.b and v.c. | ||
|
||
// CHECK-DAG: [[STR:%.+]] = getelementptr inbounds [7 x i64], ptr [[SIZES]], i32 0, i32 0 | ||
// CHECK-DAG: store i64 %{{.+}}, ptr [[STR]], align 8 | ||
// CHECK-DAG: [[X:%.+]] = getelementptr inbounds [7 x i64], ptr [[SIZES]], i32 0, i32 1 | ||
// CHECK-DAG: store i64 %{{.+}}, ptr [[X]], align 8 | ||
// CHECK-DAG: [[PAD:%.+]] = getelementptr inbounds [7 x i64], ptr [[SIZES]], i32 0, i32 2 | ||
// CHECK-DAG: store i64 %{{.+}}, ptr [[PAD]], align 8 | ||
// CHECK-DAG: [[BC:%.+]] = getelementptr inbounds [7 x i64], ptr [[SIZES]], i32 0, i32 3 | ||
// CHECK-DAG: store i64 %{{.+}}, ptr [[BC]], align 8 |
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.
auto generate check lines pls
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.
This one though I'm not sure how to do -- the check lines for the new copy-gaps tests are manually written, as it appears were the check lines for the altered test target_map_codegen_35.cpp (which seems to be the only extant test that this patch affects). Would it be better to have auto-generated check lines for the whole generated output for the new tests? That seems like it'd be more brittle, to me.