diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 7cb93f3c5b050..fc7f17003f99c 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -7733,9 +7733,26 @@ static void processFunctionInstantiation(Sema &S, FD->setInstantiationIsPending(false); } +static std::unique_ptr +createCrossABIMangleContext(ASTContext &Ctx) { + // For offload compilation with cross-ABI scenarios (e.g., Microsoft host + // + Itanium device), use device mangling context to ensure consistent + // symbol name mangling between host and device compilations. + 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 Sema::PerformPendingInstantiations(bool LocalOnly, bool AtEndOfTU) { + // Use cross-ABI aware mangling context to handle offload scenarios where + // host and device may use different ABIs (e.g., Windows+CUDA, Windows+HIP). std::unique_ptr MangleCtx( - getASTContext().createMangleContext()); + createCrossABIMangleContext(getASTContext())); std::deque DelayedImplicitInstantiations; while (!PendingLocalImplicitInstantiations.empty() || (!LocalOnly && !PendingInstantiations.empty())) { 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 diff --git a/test_cross_abi_mangling.cpp b/test_cross_abi_mangling.cpp new file mode 100644 index 0000000000000..bb4ada1ea0c08 --- /dev/null +++ b/test_cross_abi_mangling.cpp @@ -0,0 +1,19 @@ +// Test case for cross-ABI kernel name mangling (Windows+CUDA scenario) +// This should compile and link correctly on Windows targeting CUDA + +#include + +template class KernelName; + +// Simulate SYCL kernel lambda - this will be instantiated +template void kernel_func() { + // Empty kernel body +} + +int main() { + // Instantiate the kernel template + kernel_func>(); + + std::cout << "Cross-ABI mangling test passed!" << std::endl; + return 0; +}