-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL] Optimize SYCL framework functions with -O0 #7376
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
34 commits
Select commit
Hold shift + click to select a range
acd84e0
[SYCL] Emit "sycl-framework" metadata attached to funcions/methods in…
maksimsab 0e222f5
[SYCL] Add -fsycl-optimize-framework command line option in Clang Dri…
maksimsab 9cb70d7
[SYCL] Add SYCLLowerIR/IR/PassAdaptors.h
maksimsab 41bbeb7
[SYCL] Add a SYCL framework optimization pipeline to LLVM O0 default …
maksimsab 8b66cf2
[SYCL] fix code review remarks
maksimsab ad2f3cd
[SYCL] Use sycl::kernel_single_task mock in sycl-framework-metadata1.cpp
maksimsab 6bc843a
Merge branch 'sycl' into add_new_debug_mode
maksimsab 060da0e
[SYCL] Fix RemoveFuncAttrsFromSYCLFrameworkFuncs pass
maksimsab 1c73c82
[SYCL] Fix ModuleToSYCLFrameworkFunctionPassAdaptor
maksimsab a55eb69
[SYCL] Support fsycl-optimize-framework in clang_cl Driver.
maksimsab 3d274c6
Merge branch 'sycl' into add_new_debug_mode
maksimsab 2f4c38a
[SYCL] Fix code style and test
maksimsab c5b90e8
[SYCL] Adjust SROA usage to upstream
maksimsab c330040
[SYCL] remove test
maksimsab 22a85f3
[SYCL] add marshalling for fsycl_optimize_framework option
maksimsab 8be1488
[SYCL] add AddFuncAttrsFromSYCLFrameworkFuncs pass
maksimsab fbdc0be
[SYCL] replace fsycl-optimize-framework with
maksimsab ad46aa3
Merge branch 'sycl' into add_new_debug_mode
maksimsab b3b866e
[SYCL] add Inline passes to pipeline
maksimsab 15d364c
[SYCL] fix code style
maksimsab 9e1d8c8
[SYCL] remove leftover and correct option's description
maksimsab 56eb938
Merge branch 'sycl' into add_new_debug_mode
maksimsab 71975d2
[SYCL] simplify optimization pipeline
maksimsab febec47
[SYCL] remove !sycl-framework metadata
maksimsab 0ab1fe8
[SYCL] fix SYCLFrameworkOptimization.h description
maksimsab ebd116f
[SYCL] fix code style
maksimsab 2648088
[SYCL] fix CodeGenSYCL tests
maksimsab 1670049
[SYCL] add comment and fix a typo
maksimsab 77eba39
[SYCL] return noinline,optnone attrs back more accurately
maksimsab ba2fe26
[SYCL] adjust test to error message
maksimsab cc077eb
[SYCL] use regex for matching function attributes in tests
maksimsab 524966b
[SYCL] remove AddDebugFuncsAttrs pass
maksimsab 7b4391f
[SYCL] remove useless assertion
maksimsab 91f6d96
[SYCL] correct test description
maksimsab 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
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
52 changes: 52 additions & 0 deletions
52
clang/test/CodeGenSYCL/sycl-optimize-non-user-code-func-attrs1.cpp
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 @@ | ||
// Test checks that noinline and optnone function's attributes aren't attached | ||
// to functions whose topmost namespace is sycl. | ||
|
||
// RUN: %clang_cc1 -fsycl-is-device -O0 -fsycl-optimize-non-user-code -internal-isystem %S/Inputs -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s | ||
|
||
#include "sycl.hpp" | ||
|
||
// Check that kernel marked with noinline and optnone func attrs. | ||
// CHECK: spir_kernel {{.*}} #[[KERNEL_ATTRS:[0-9]+]] | ||
|
||
// Check that user code contain noinline and optnone func attrs. | ||
// CHECK: define {{.*}} @_Z3foov() #[[FOO_ATTRS:[0-9]+]] | ||
int foo() { | ||
return 123; | ||
} | ||
|
||
// Check that all functions on sycl::* namespace do not contain | ||
// noinline and optnone func attrs. | ||
namespace sycl { | ||
// CHECK: define {{.*}} @_ZN4sycl4bar1Ev() #[[BAR1_ATTRS:[0-9]+]] | ||
void bar1() {} | ||
|
||
namespace V1 { | ||
// bar1 and bar2 have common function attrs | ||
// CHECK: define {{.*}} @_ZN4sycl2V14bar2Ev() #[[BAR1_ATTRS]] | ||
void bar2() {} | ||
} | ||
} | ||
|
||
// Check that V1::sycl::* functions do not contain noinline and optnone | ||
// func attrs since topmost namespace is V1 instead of sycl. | ||
namespace V1 { | ||
namespace sycl { | ||
// foo and bar3 have common function attrs | ||
// CHECK: define {{.*}} @_ZN2V14sycl4bar3Ev() #[[FOO_ATTRS]] | ||
void bar3() {} | ||
} | ||
} | ||
|
||
// Check attributes | ||
// CHECK-DAG: attributes #[[KERNEL_ATTRS]] = {{.*}} {{noinline|optnone}} {{.*}} {{noinline|optnone}} | ||
// CHECK-DAG: attributes #[[FOO_ATTRS]] = {{.*}} noinline {{.*}} optnone | ||
// CHECK-NOT: attributes #[[BAR1_ATTRS]] = {{.*}} {{noinline|optnone}} | ||
|
||
int main() { | ||
sycl::kernel_single_task<class kernel>([]() { | ||
foo(); | ||
sycl::bar1(); | ||
sycl::V1::bar2(); | ||
V1::sycl::bar3(); | ||
}); | ||
} |
31 changes: 31 additions & 0 deletions
31
clang/test/CodeGenSYCL/sycl-optimize-non-user-code-func-attrs2.cpp
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,31 @@ | ||
// Test checks that noinline and optnone function's attributes aren't attached | ||
// to functions whose topmost namespace is not sycl. | ||
|
||
// RUN: %clang_cc1 -fsycl-is-device -O0 -fsycl-optimize-non-user-code -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s | ||
|
||
// Check that kernel contains noinline and optnone func attrs. | ||
// CHECK: define {{.*}} @_ZTSZ4mainE6kernel() #[[KERNEL_ATTRS:[0-9]+]] | ||
|
||
// Check that 'anonymous namespace'::sycl::* functions contains | ||
// noinline and optnone func attrs since topmost namespace is anonymous | ||
// instead of sycl. | ||
namespace { | ||
namespace sycl { | ||
// CHECK: define {{.*}} @_ZN12_GLOBAL__N_14sycl4bar4Ev() #[[BAR4_ATTRS:[0-9]+]] | ||
void bar4() {} | ||
} | ||
} | ||
|
||
template <typename name, typename Func> | ||
__attribute__((sycl_kernel)) void kernel_single_task(const Func &func) { | ||
func(); | ||
} | ||
|
||
// CHECK: attributes #[[KERNEL_ATTRS]] = {{.*}} noinline {{.*}} optnone | ||
// CHECK: attributes #[[BAR4_ATTRS]] = {{.*}} noinline {{.*}} optnone | ||
|
||
int main() { | ||
kernel_single_task<class kernel>([]() { | ||
sycl::bar4(); | ||
}); | ||
} |
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,20 @@ | ||
// RUN: %clangxx -fsycl -O0 -### %s 2>&1 | FileCheck %s -check-prefix=NO-OPT-CHECK | ||
// NO-OPT-CHECK-NOT: fsycl-optimize-non-user-code | ||
|
||
// RUN: %clangxx -fsycl -O0 -fsycl-optimize-non-user-code -### %s 2>&1 | FileCheck %s -check-prefix=OPT-CHECK | ||
// OPT-CHECK: fsycl-optimize-non-user-code | ||
|
||
// RUN: not %clangxx -fsycl -O1 -fsycl-optimize-non-user-code %s 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR | ||
// RUN: not %clangxx -fsycl -fsycl-optimize-non-user-code %s 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR | ||
// CHECK-ERROR: error: -fsycl-optimize-non-user-code option can be used only in conjunction with -O0 | ||
|
||
// Check cases for Microsoft Windows Driver. | ||
// RUN: %clang_cl -fsycl -Od -### %s 2>&1 | FileCheck %s -check-prefix=NO-OPT-WIN-CHECK | ||
// NO-OPT-WIN-CHECK-NOT: fsycl-optimize-non-user-code | ||
|
||
// RUN: %clang_cl -fsycl -Od -fsycl-optimize-non-user-code -### %s 2>&1 | FileCheck %s -check-prefix=OPT-WIN-CHECK | ||
// OPT-WIN-CHECK: fsycl-optimize-non-user-code | ||
|
||
// RUN: not %clang_cl -fsycl -O1 -fsycl-optimize-non-user-code %s 2>&1 | FileCheck %s -check-prefix=CHECK-WIN-ERROR | ||
// RUN: not %clang_cl -fsycl -fsycl-optimize-non-user-code %s 2>&1 | FileCheck %s -check-prefix=CHECK-WIN-ERROR | ||
// CHECK-WIN-ERROR: error: -fsycl-optimize-non-user-code option can be used only in conjunction with -Od |
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
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.
Uh oh!
There was an error while loading. Please reload this page.