diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp index cf34c5aaeaf31..f2fc0b0cae4d5 100644 --- a/clang/lib/Sema/SemaSYCL.cpp +++ b/clang/lib/Sema/SemaSYCL.cpp @@ -5369,9 +5369,24 @@ void SemaSYCL::copyDeviceKernelAttrs(CXXMethodDecl *CallOperator) { } } +static std::unique_ptr +createSYCLCrossABIMangleContext(ASTContext &Ctx) { + // For SYCL offload compilation with cross-ABI scenarios (e.g., Microsoft + // host + Itanium device on Windows+CUDA), use device mangling context to + // ensure consistent kernel name mangling between host and device. + const TargetInfo *AuxTarget = Ctx.getAuxTargetInfo(); + if (AuxTarget && Ctx.getTargetInfo().getCXXABI().isMicrosoft() && + AuxTarget->getCXXABI().isItaniumFamily()) { + return std::unique_ptr( + Ctx.createDeviceMangleContext(*AuxTarget)); + } + // Same ABI or no offload target: use standard mangling + return std::unique_ptr(Ctx.createMangleContext()); +} + void SemaSYCL::SetSYCLKernelNames() { std::unique_ptr MangleCtx( - getASTContext().createMangleContext()); + createSYCLCrossABIMangleContext(getASTContext())); // We assume the list of KernelDescs is the complete list of kernels needing // to be rewritten. for (const std::pair &Pair : @@ -5890,7 +5905,7 @@ void SemaSYCL::finalizeFreeFunctionKernels() { KernelObjVisitor Visitor{*this}; Visitor.VisitFunctionParameters(kernel, IntHeader); std::unique_ptr MangleCtx( - getASTContext().createMangleContext()); + createSYCLCrossABIMangleContext(getASTContext())); std::string Name, MangledName; std::tie(Name, MangledName) = constructFreeFunctionKernelName(kernel, *MangleCtx); diff --git a/sycl/test-e2e/Printf/mixed-address-space.cpp b/sycl/test-e2e/Printf/mixed-address-space.cpp index 1e256f5619288..126891644535c 100644 --- a/sycl/test-e2e/Printf/mixed-address-space.cpp +++ b/sycl/test-e2e/Printf/mixed-address-space.cpp @@ -2,8 +2,6 @@ // for constant and generic address space can be used in the same module. // // UNSUPPORTED: target-amd -// XFAIL: cuda && windows -// XFAIL-TRACKER: https://github.com/intel/llvm/issues/14733 // FIXME: Drop the test once generic AS support is considered stable and the // dedicated constant AS overload of printf is removed from the library. // diff --git a/sycl/test-e2e/Printf/percent-symbol.cpp b/sycl/test-e2e/Printf/percent-symbol.cpp index 364016220a62f..60f483f880e04 100644 --- a/sycl/test-e2e/Printf/percent-symbol.cpp +++ b/sycl/test-e2e/Printf/percent-symbol.cpp @@ -5,8 +5,6 @@ // [1]: https://en.cppreference.com/w/cpp/io/c/fprintf // // UNSUPPORTED: target-amd -// XFAIL: cuda && windows -// XFAIL-TRACKER: https://github.com/intel/llvm/issues/14733 // RUN: %{build} -o %t.out // RUN: %{run} %t.out | FileCheck %s // FIXME: Remove dedicated constant address space testing once generic AS