-
Notifications
You must be signed in to change notification settings - Fork 0
[clang-sycl-linker] Replace llvm-link with API calls #4
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
base: master
Are you sure you want to change the base?
Changes from 11 commits
ce34ccd
ae0210f
ee487ff
a9255b4
e0d1859
c1611f0
596488c
454c386
f4cc3cf
d76a3a1
7249cb8
59c0bcd
a5acaa3
0649b61
987ab66
917987d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,36 @@ | ||||||||||||
| ; ModuleID = 'libsycl.cpp' | ||||||||||||
| source_filename = "libsycl.cpp" | ||||||||||||
| target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1" | ||||||||||||
| target triple = "spirv64" | ||||||||||||
|
||||||||||||
| ; ModuleID = 'libsycl.cpp' | |
| source_filename = "libsycl.cpp" | |
| target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1" | |
| target triple = "spirv64" | |
| target triple = "spirv64" |
Please, remove from the tests as well.
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.
Done as part of upcoming commit. Thanks
Outdated
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 prefer to have simpler code for the library (and tests):
- Unmingled names.
- No unnecessary attributes.
- Less code. Do we need 4 library functions? I would leave just one:
define spir_func i32 addFive(i32 %x) {
%res = add i32 %x, 5
ret i32 %res
}It's easier to maintain and read.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| ; ModuleID = 'test1.cpp' | ||
| source_filename = "test1.cpp" | ||
| target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1" | ||
| target triple = "spirv64" | ||
|
|
||
| ; Function Attrs: mustprogress noinline | ||
| define spir_func noundef i32 @_Z9foo_func1ii(i32 noundef %a, i32 noundef %b) local_unnamed_addr #0 { | ||
|
||
| entry: | ||
| %call = tail call spir_func noundef i32 @_Z9lib_func4i(i32 noundef %b) | ||
| %call1 = tail call spir_func noundef i32 @_Z9bar_func1ii(i32 noundef %a, i32 noundef %call) | ||
| ret i32 %call1 | ||
| } | ||
|
|
||
| declare spir_func noundef i32 @_Z9bar_func1ii(i32 noundef, i32 noundef) local_unnamed_addr #1 | ||
|
|
||
| declare spir_func noundef i32 @_Z9lib_func4i(i32 noundef) local_unnamed_addr #1 | ||
|
|
||
| ; Function Attrs: mustprogress | ||
| define spir_func noundef i32 @_Z9foo_func2iii(i32 noundef %c, i32 noundef %d, i32 noundef %e) local_unnamed_addr #2 { | ||
| entry: | ||
| %call = tail call spir_func noundef i32 @_Z9foo_func1ii(i32 noundef %c, i32 noundef %d) | ||
| %mul = mul nsw i32 %call, %e | ||
| ret i32 %mul | ||
| } | ||
|
|
||
| attributes #0 = { mustprogress noinline "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } | ||
| attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } | ||
| attributes #2 = { mustprogress "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| ; ModuleID = 'test2.cpp' | ||
| source_filename = "test2.cpp" | ||
| target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1" | ||
| target triple = "spirv64" | ||
|
|
||
| ; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) | ||
| define spir_func noundef i32 @_Z9bar_func1ii(i32 noundef %a, i32 noundef %b) local_unnamed_addr #0 { | ||
| entry: | ||
| %add = add nsw i32 %b, %a | ||
| ret i32 %add | ||
| } | ||
|
|
||
| ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) | ||
| define spir_func noundef i32 @_Z9bar_func2iii(i32 noundef %c, i32 noundef %d, i32 noundef %e) local_unnamed_addr #1 { | ||
|
||
| entry: | ||
| %call = tail call spir_func noundef i32 @_Z9bar_func1ii(i32 noundef %c, i32 noundef %d) | ||
| %add = add nsw i32 %call, %e | ||
| ret i32 %add | ||
| } | ||
|
|
||
| attributes #0 = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } | ||
| attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| ; ModuleID = 'test3.cpp' | ||
| source_filename = "test3.cpp" | ||
| target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1" | ||
| target triple = "spirv64" | ||
|
|
||
| ; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) | ||
| define spir_func noundef i32 @_Z9bar_func1ii(i32 noundef %a, i32 noundef %b) local_unnamed_addr #0 { | ||
| entry: | ||
| %mul = shl nsw i32 %a, 1 | ||
| %add = add nsw i32 %mul, %b | ||
| ret i32 %add | ||
| } | ||
|
|
||
| ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) | ||
| define spir_func noundef i32 @_Z9baz_func1i(i32 noundef %a) local_unnamed_addr #1 { | ||
| entry: | ||
| %add = add nsw i32 %a, 5 | ||
| %call = tail call spir_func noundef i32 @_Z9bar_func1ii(i32 noundef %a, i32 noundef %add) | ||
| ret i32 %call | ||
| } | ||
|
|
||
| attributes #0 = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } | ||
| attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # RUN: llvm-as %S/Inputs/test1.ll -o %t.test1.bc | ||
| # RUN: llvm-as %S/Inputs/test2.ll -o %t.test2.bc | ||
| # RUN: llvm-as %S/Inputs/test3.ll -o %t.test3.bc | ||
| # RUN: llvm-as %S/Inputs/libsycl.ll -o %t.libsycl.bc | ||
| # RUN: clang-sycl-linker %t.test1.bc %t.test2.bc -triple spirv64 -o test.spv --print-linked-module 2>&1 | FileCheck %s --check-prefix=CHECK-SIMPLE | ||
|
|
||
| # RUN: not clang-sycl-linker %t.test2.bc %t.test3.bc -triple spirv64 -o test.spv --print-linked-module 2>&1 | FileCheck %s --check-prefix=CHECK-MULTIPLE-DEFS | ||
|
|
||
| # RUN: clang-sycl-linker %t.test1.bc %t.test2.bc -device-libs=%t.libsycl.bc -library-path= -triple spirv64 -o test.spv --print-linked-module 2>&1 | FileCheck %s --check-prefix=CHECK-DEVICE-LIB | ||
|
|
||
| ; CHECK-SIMPLE: define {{.*}}foo_func1{{.*}} | ||
| ; CHECK-SIMPLE: define {{.*}}foo_func2{{.*}} | ||
| ; CHECK-SIMPLE: define {{.*}}bar_func1{{.*}} | ||
| ; CHECK-SIMPLE: define {{.*}}bar_func2{{.*}} | ||
|
|
||
| ;CHECK-MULTIPLE-DEFS: error: Linking globals named {{.*}}bar_func1{{.*}} symbol multiply defined! | ||
|
|
||
| ; CHECK-DEVICE-LIB: define {{.*}}foo_func1{{.*}} | ||
| ; CHECK-DEVICE-LIB: define {{.*}}foo_func2{{.*}} | ||
| ; CHECK-DEVICE-LIB: define {{.*}}bar_func1{{.*}} | ||
| ; CHECK-DEVICE-LIB: define {{.*}}bar_func2{{.*}} | ||
|
||
|
|
||
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.
Let's put new files to clang/test/Driver/Inputs/SYCL/* directory.