-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] Emit an aliased function only if it is used #2430
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s | ||
// Test that aliasing does not force an unused entity to be emitted | ||
|
||
// CHECK-NOT: define spir_func void @unused_func() | ||
extern "C" void unused_func() {} | ||
// CHECK-NOT: @unused_aliaser | ||
extern "C" void unused_aliaser() __attribute__((alias("unused_func"))); | ||
// CHECK-NOT: @unused_int | ||
int unused_int = 3; | ||
// CHECK-NOT: @alias_unused_int | ||
extern int alias_unused_int __attribute__((alias("unused_int"))); | ||
|
||
// CHECK-DAG: define spir_func void @used_func() | ||
extern "C" void used_func() {} | ||
// CHECK-DAG: @aliaser = alias void (), void ()* @used_func | ||
extern "C" void aliaser() __attribute__((alias("used_func"))); | ||
|
||
// CHECK-DAG: define spir_func void @func() | ||
extern "C" void func() {} | ||
// CHECK-DAG: @used_aliaser = alias void (), void ()* @func | ||
extern "C" void used_aliaser() __attribute__((alias("func"))); | ||
|
||
// CHECK-DAG: @used_int = addrspace(1) constant i32 5, align 4 | ||
extern "C" const int used_int = 5; | ||
// CHECK-DAG: @alias_used_int = alias i32, i32 addrspace(1)* @used_int | ||
extern "C" const int alias_used_int __attribute__((alias("used_int"))); | ||
// CHECK-DAG: @vint = addrspace(1) constant i32 7, align 4 | ||
extern "C" const int vint = 7; | ||
// CHECK-DAG: @used_alias_used_int = alias i32, i32 addrspace(1)* @vint | ||
extern "C" const int used_alias_used_int __attribute__((alias("vint"))); | ||
|
||
// CHECK-DAG: define spir_func void @{{.*}}bar{{.*}} | ||
void bar(const int &i) {} | ||
|
||
// CHECK-DAG: define spir_func void @{{.*}}foo{{.*}} | ||
void __attribute__((sycl_device)) foo() { | ||
// CHECK-DAG: call spir_func void @{{.*}}bar{{.*}}@used_int | ||
bar(used_int); | ||
// CHECK-DAG: call spir_func void @{{.*}}bar{{.*}}@used_alias_used_int | ||
bar(used_alias_used_int); | ||
// CHECK-DAG: call spir_func void @used_func() | ||
used_func(); | ||
// CHECK-DAG: call spir_func void @used_aliaser() | ||
used_aliaser(); | ||
} |
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.
Seems like
alias
attribute can be also applied to a global variable. Could you please add corresponding tests?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.
Thanks, I did this. (I didn't change the title to avoid needing to force-push, but I will do that when there are no further code-review comments.)
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 think test renaming shouldn't require doing force-push. See #2420 for example. It has a commit which just renames a test - 8b24581 . I didn't do any force-pushes there. Also, current title works for me as well.