From f011811977510572c50c8c5159cf2ab4153acf6e Mon Sep 17 00:00:00 2001 From: "Meszaros, Gergely" Date: Mon, 22 Sep 2025 10:02:33 +0000 Subject: [PATCH] [libspirv][remangler] Don't remangle internal functions. There is no need to remangle functions with local (internal/private) linkage, they won't be called from outside libclc. Skipping them avoids issues with compiler added suffixes like ".0". We could fix remangling to handle those suffixes, but skipping them is simpler, and we don't expect suffixes on externally visible functions anyway. Skipping over internal functions could also improve performance when remangling large modules with many internal functions. This fixes an issue we see when building libclc for a downstream target, the error was: ```plaintext [11/22] Generating ../../lib/clc/remangled-l32-signed_char.libspirv-.bc FAILED: lib/clc/remangled-l32-signed_char.libspirv-.bc llvm/lib/clc/remangled-l32-signed_char.libspirv-.bc cd llvm/tools/libclc && cmake -E make_directory llvm/./lib/clc && llvm/bin/libclc-remangler -o llvm/./lib/clc/remangled-l32-signed_char.libspirv-.bc --triple= --long-width=l32 --char-signedness=signed --input-ir=llvm/./lib/clc/libspirv-.bc llvm/./lib/clc/libclc_dummy_in.cc Unhandled type: __clc_copysign(float, float) Unhandled type. UNREACHABLE executed at llvm/libclc/utils/libclc-remangler/LibclcRemangler.cpp:590! ``` due to a function named `@_Z14__clc_copysignff.9` with internal linkage. --- libclc/utils/libclc-remangler/LibclcRemangler.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libclc/utils/libclc-remangler/LibclcRemangler.cpp b/libclc/utils/libclc-remangler/LibclcRemangler.cpp index 526e07ec0164f..440a84619cd96 100644 --- a/libclc/utils/libclc-remangler/LibclcRemangler.cpp +++ b/libclc/utils/libclc-remangler/LibclcRemangler.cpp @@ -883,6 +883,9 @@ class LibCLCRemangler : public ASTConsumer { } bool remangleFunction(Function &Func, llvm::Module *M) { + if (Func.hasLocalLinkage()) + return true; + if (!Func.getName().starts_with("_Z")) return true;