From cb60514c2902bc67ab66c9b6e836af83b592b377 Mon Sep 17 00:00:00 2001 From: MrLop Date: Tue, 29 Apr 2025 15:06:52 +0800 Subject: [PATCH] [IRMover] Fix symver Copy @@ When FunctionImport uses IRMover to copy a function from other thinLTO modules, it will copy the related .symver asm. However, like ".symver foo, foo@@foo_1.0" sets the default version, requiring the corresponding function to be defined. I believe that as a module using this function, it only need to know the version corresponding to the symbol name it uses, so the copied asm should be changed to ".symver foo, foo@foo_1.0". To solve this problem, the code in IRMover needs to be modified. Signed-off-by: MrLop --- llvm/lib/Linker/IRMover.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index ab960e021d4d..60b6038e9dfc 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -1622,7 +1622,14 @@ Error IRLinker::run() { SmallString<256> S(".symver "); S += Name; S += ", "; - S += Alias; + auto Pos = Alias.find("@@"); + if (Pos != StringRef::npos && !Alias.startswith("@@@")) { + S += Alias.substr(0, Pos); + S += '@'; + S += Alias.substr(Pos + 2); + } else { + S += Alias; + } DstM.appendModuleInlineAsm(S); } }); -- Gitee