Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 24 additions & 3 deletions llvm/lib/SYCLLowerIR/GlobalOffset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,15 @@ void GlobalOffsetPass::addImplicitParameterToCallers(

for (User *U : Users) {
auto *CallToOld = dyn_cast<CallInst>(U);
if (!CallToOld)
return;
// Only direct calls where `Callee` is the callee are handled. If `Callee`
// is used in any other way (e.g. its address is taken or it is passed as a
// call argument), the implicit offset argument cannot be threaded through
// that use. Skipping such uses avoids constructing a call with a
// mismatched signature (which would otherwise crash the compiler). Note we
// must `continue` rather than `return` so remaining valid callers are still
// processed.
if (!CallToOld || CallToOld->getCalledOperand() != Callee)
continue;

auto *Caller = CallToOld->getFunction();

Expand Down Expand Up @@ -273,10 +280,24 @@ void GlobalOffsetPass::addImplicitParameterToCallers(
}
ImplicitOffsets.push_back(ImplicitOffset);

// Build the callee type from the *original* call's function type rather
// than from the callee's declared signature, then append the implicit
// offset parameter. LLVM allows a call whose function type differs from
// the callee's declared type (e.g. SYCL device code frequently calls
// functions through address-space-mismatched pointer types such as
// generic `ptr` vs `ptr addrspace(4)`). Using the callee's declared
// signature here would create a call whose argument types disagree with
// the parameter types, tripping a "bad signature" assertion.
FunctionType *OldCallTy = CallToOld->getFunctionType();
SmallVector<Type *, 8> NewParamTypes(OldCallTy->params());
NewParamTypes.push_back(ImplicitOffset->getType());
FunctionType *NewCallTy = FunctionType::get(
OldCallTy->getReturnType(), NewParamTypes, OldCallTy->isVarArg());

// Replace call to other function (which now has a new parameter),
// with a call including the new parameter to that same function.
auto *NewCallInst = CallInst::Create(
/* Ty= */ CalleeWithImplicitParam->getFunctionType(),
/* Ty= */ NewCallTy,
/* Func= */ CalleeWithImplicitParam,
/* Args= */ ImplicitOffsets,
/* NameStr= */ Twine(),
Expand Down
3 changes: 0 additions & 3 deletions sycl/test-e2e/Assert/assert_in_kernels.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// REQUIRES: linux

// UNSUPPORTED: hip
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/7634
//
// XFAIL: (opencl && gpu)
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/11364

Expand Down
3 changes: 0 additions & 3 deletions sycl/test-e2e/Assert/assert_in_multiple_tus.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// REQUIRES: linux

// UNSUPPORTED: hip
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/7634
//
// UNSUPPORTED: cuda
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/8832
//
Expand Down
3 changes: 0 additions & 3 deletions sycl/test-e2e/Assert/assert_in_multiple_tus_one_ndebug.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// REQUIRES: linux

// UNSUPPORTED: hip
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/7634
//
// UNSUPPORTED: cuda
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/8832
//
Expand Down
3 changes: 0 additions & 3 deletions sycl/test-e2e/Assert/assert_in_one_kernel.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// REQUIRES: linux

// UNSUPPORTED: hip
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/7634
//
// XFAIL: (opencl && gpu)
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/11364

Expand Down
4 changes: 1 addition & 3 deletions sycl/test-e2e/Assert/assert_in_simultaneous_kernels.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// REQUIRES: linux
// FIXME: Flaky on HIP and cuda
// UNSUPPORTED: hip
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/22300
// FIXME: Flaky on cuda
// UNSUPPORTED: cuda
// RUN: %{build} -o %t.out %threads_lib
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// FIXME flaky fail on CUDA and HIP
// FIXME flaky fail on CUDA
// UNSUPPORTED: cuda
//
// UNSUPPORTED: hip
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/22300
//
// XFAIL: (opencl && gpu)
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/11364
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// FIXME flaky fail on CUDA
// UNSUPPORTED: cuda, hip
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/7634
// UNSUPPORTED: cuda
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/8832
//
// XFAIL: (opencl && gpu)
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/11364
Expand Down
4 changes: 0 additions & 4 deletions sycl/test-e2e/Assert/check_resource_leak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
// Therefore not planned to be supported at the moment. See
// https://github.com/intel/llvm/issues/22228

// TODO: Fails at JIT compilation for some reason.
// UNSUPPORTED: hip
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/22300

// XFAIL: target-native_cpu
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/20142
#define SYCL_FALLBACK_ASSERT 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// FIXME unsupported on CUDA and HIP until fallback libdevice becomes available
// FIXME unsupported on CUDA until fallback libdevice becomes available
// UNSUPPORTED: cuda
//
// UNSUPPORTED: hip
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/22300
//
// RUN: %{build} -o %t.out
//
// RUN: env SYCL_UR_TRACE=2 %{run} %t.out &> %t.txt ; FileCheck %s --input-file %t.txt
Expand Down