Skip to content
Draft
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
19 changes: 18 additions & 1 deletion clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7733,9 +7733,26 @@ static void processFunctionInstantiation(Sema &S,
FD->setInstantiationIsPending(false);
}

static std::unique_ptr<MangleContext>
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<MangleContext>(
Ctx.createDeviceMangleContext(*AuxTarget));
}
// Same ABI or no offload target: use standard mangling
return std::unique_ptr<MangleContext>(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<MangleContext> MangleCtx(
getASTContext().createMangleContext());
createCrossABIMangleContext(getASTContext()));
std::deque<PendingImplicitInstantiation> DelayedImplicitInstantiations;
while (!PendingLocalImplicitInstantiations.empty() ||
(!LocalOnly && !PendingInstantiations.empty())) {
Expand Down
2 changes: 0 additions & 2 deletions sycl/test-e2e/Printf/mixed-address-space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down
2 changes: 0 additions & 2 deletions sycl/test-e2e/Printf/percent-symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions test_cross_abi_mangling.cpp
Original file line number Diff line number Diff line change
@@ -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 <iostream>

template <typename T> class KernelName;

// Simulate SYCL kernel lambda - this will be instantiated
template <typename T> void kernel_func() {
// Empty kernel body
}

int main() {
// Instantiate the kernel template
kernel_func<KernelName<int>>();

std::cout << "Cross-ABI mangling test passed!" << std::endl;
return 0;
}
Loading