Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
34a11ca
Provide supports for decomposable structs
lbushi25 May 28, 2025
edec2b4
Merge branch 'sycl' of https://github.com/lbushi25/llvm into sycl
lbushi25 May 28, 2025
c9680a2
Revert "Provide supports for decomposable structs"
lbushi25 Jun 3, 2025
b932fe6
Merge branch 'sycl' of https://github.com/lbushi25/llvm into sycl
lbushi25 Jun 3, 2025
6b6da56
Merge branch 'sycl' of https://github.com/lbushi25/llvm into sycl
lbushi25 Jun 10, 2025
ceaabfd
Merge branch 'sycl' of https://github.com/lbushi25/llvm into sycl
lbushi25 Jun 23, 2025
714839e
Merge branch 'sycl' of https://github.com/lbushi25/llvm into sycl
lbushi25 Jul 22, 2025
01b6936
Remove debugging artifacts from E2E test
lbushi25 Aug 11, 2025
dbc7f3e
Merge branch 'sycl' of https://github.com/lbushi25/llvm into sycl
lbushi25 Aug 11, 2025
3d3a618
Disable dear argument elimination for free function kernels
lbushi25 Aug 12, 2025
20bf581
Update DeadArgumentElimination.cpp
lbushi25 Aug 12, 2025
a95f22d
Update free_function_kernels.cpp
lbushi25 Aug 12, 2025
1060e14
Add test for dead argument elimination disabling for free function ke…
lbushi25 Aug 13, 2025
90422fb
Merge branch 'disable_dead_arg_elimination_for_free_function_kernels'…
lbushi25 Aug 13, 2025
2cb0ca7
Fix typo in RUN command
lbushi25 Aug 13, 2025
964e5af
Rename test and add an explnatory comment
lbushi25 Aug 13, 2025
6704b61
Refactor tests
lbushi25 Aug 14, 2025
e6740fd
Improve comments
lbushi25 Aug 14, 2025
4f76afe
Improve comments
lbushi25 Aug 14, 2025
54b372b
Update sycl-kernels-neg.ll
lbushi25 Aug 15, 2025
17b7eda
Run script on LIT test
lbushi25 Aug 18, 2025
dc92d56
Fix conflict
lbushi25 Aug 18, 2025
8723efe
Fix E2E failures
lbushi25 Aug 18, 2025
28569aa
Revert "Fix E2E failures"
lbushi25 Aug 19, 2025
01e13bc
Comment out failing test case
lbushi25 Aug 19, 2025
06bc971
Update llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
lbushi25 Aug 20, 2025
e83e510
Remove extra blank line
lbushi25 Aug 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,17 @@ void DeadArgumentEliminationPass::surveyFunction(const Function &F) {
return;
}

// Do not modify arguments when the SYCL kernel is a free function kernel.
// In this case, the user sets the arguments of the kernel by themselves
// and dead argument elimination may interfere with their expectations.
const bool FuncIsSyclFreeFunctionKernel =
F.hasFnAttribute("sycl-single-task-kernel") ||
F.hasFnAttribute("sycl-nd-range-kernel");
if (FuncIsSyclFreeFunctionKernel) {
markFrozen(F);
return;
}

LLVM_DEBUG(
dbgs() << "DeadArgumentEliminationPass - Inspecting callers for fn: "
<< F.getName() << "\n");
Expand Down
25 changes: 24 additions & 1 deletion llvm/test/Transforms/DeadArgElim/sycl-kernels-neg.ll
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,30 @@ define weak_odr void @NotASpirKernel(float %arg1, float %arg2) {

define weak_odr void @ESIMDKernel(float %arg1, float %arg2) !sycl_explicit_simd !0 {
; CHECK-LABEL: define {{[^@]+}}@ESIMDKernel
; CHECK-SAME: (float [[ARG1:%.*]], float [[ARG2:%.*]]) !sycl_explicit_simd !0 {
; CHECK-SAME: (float [[ARG1:%.*]], float [[ARG2:%.*]]) {{.*}}{
; CHECK-NEXT: call void @foo(float [[ARG1]])
; CHECK-NEXT: ret void
;
call void @foo(float %arg1)
ret void
}

; The following two tests ensure that dead arguments are not eliminated
; from a free function kernel.

define weak_odr spir_kernel void @FreeFuncKernelSingleTask(float %arg1, float %arg2) "sycl-single-task-kernel"="0" {
; CHECK-LABEL: define {{[^@]+}}@FreeFuncKernelSingleTask
; CHECK-SAME: (float [[ARG1:%.*]], float [[ARG2:%.*]]) #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: call void @foo(float [[ARG1]])
; CHECK-NEXT: ret void
;
call void @foo(float %arg1)
ret void
}

define weak_odr spir_kernel void @FreeFuncKernelNdRange(float %arg1, float %arg2) "sycl-nd-range-kernel"="0" {
; CHECK-LABEL: define {{[^@]+}}@FreeFuncKernelNdRange
; CHECK-SAME: (float [[ARG1:%.*]], float [[ARG2:%.*]]) #[[ATTR1:[0-9]+]] {
; CHECK-NEXT: call void @foo(float [[ARG1]])
; CHECK-NEXT: ret void
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ int main() {
test_func_custom_type<A::B::C::TestClass>();
test_func<F<float>, float>();
test_func<F<uint32_t>, uint32_t>();
test_func<variadic_templated<double>, double>();
// Variadic template functions do not work with free function kernels. See
// CMPLRLLVM-69528.
// TODO: Uncomment the following line once the tracker is resolved.
// test_func<variadic_templated<double>, double>();
Comment on lines +176 to +179
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave review of this to @AlexeySachkov.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a regression from this patch, or is it something previously known?

Copy link
Contributor Author

@lbushi25 lbushi25 Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a regression from this patch, or is it something previously known?

I believe it's previously known. The failure described by the tracker has been happening since the test was created, it just wasn't caught by pre-commit since it only manifests with optimizations disabled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a regression from this patch, or is it something previously known?

I believe it's previously known. The failure described by the tracker has been happening since the test was created, it just wasn't caught by pre-commit since it only manifests with optimizations disabled.

Ideally, such test should be disabled in a separate PR not to cause confusion, but I'm fine with the change since we do have a tracker to analyze the issue

test_func<sum1<3, float>, float>();
test_accessor();
test_shared();
Expand Down
Loading