Skip to content
Merged
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
3 changes: 3 additions & 0 deletions libclc/utils/libclc-remangler/LibclcRemangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,9 @@ class LibCLCRemangler : public ASTConsumer {
}

bool remangleFunction(Function &Func, llvm::Module *M) {
if (Func.hasLocalLinkage())
Copy link
Contributor

@wenju-he wenju-he Sep 22, 2025

Choose a reason for hiding this comment

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

IIUC remangling is handling function parameter type and address space, but is unrelated to function linkage type.
I think the remangling process could be refined to skip functions like __clc_copysign whose parameter types don't need remangling.

Copy link
Contributor Author

@Maetveis Maetveis Sep 22, 2025

Choose a reason for hiding this comment

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

IIUC remangling is handling function parameter type and address space, but is unrelated to function linkage type.

Isn't the purpose of remangling that code compiled in SYCL (C++) language mode be able to call into libspirv functions which are compiled as OpenCL C, as there are differences between OpenCL and C++ with regards to e.g. long long size and char signedness?

If there's a function in libspirv that is internal linkage user code (the code we're linking libspirv into at user code compile time) shouldn't be calling it by definition. If it isn't being called by user code there can be no issues with C++ code looking for a different mangled name than what libspirv would provide.

I think the remangling process could be refined to skip functions like __clc_copysign whose parameter types don't need remangling.

The same problem could occur with functions that have types that need renaming.

Copy link
Contributor

Choose a reason for hiding this comment

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

If there's a function in libspirv that is internal linkage user code (the code we're linking libspirv into at user code compile time) shouldn't be calling it by definition. If it isn't being called by user code there can be no issues with C++ code looking for a different mangled name than what libspirv would provide.

Right. It seems you're correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe @Maetveis is right. The point of remangling is to give C++ code the opportunity to link against the OpenCL-C-based libclc, without there being signedness/size issues. Since functions with internal linkage shouldn't interface with C++ it should be fine to skip them during remangling.

return true;

if (!Func.getName().starts_with("_Z"))
return true;

Expand Down
Loading