[CodeGen][ARM64EC] Use alias symbol for exporting hybrid_patchable functions. (#100872)
authorJacek Caban <jacek@codeweavers.com>
Tue, 30 Jul 2024 12:22:50 +0000 (14:22 +0200)
committerTobias Hieta <tobias@hieta.se>
Wed, 31 Jul 2024 06:58:09 +0000 (08:58 +0200)
Exporting $hp_target symbol doesn't make sense, use the unmangled alias instead.
This is not compatible with MSVC, but it makes using dllexport together with
hybrid_patchable attribute possible.

(cherry picked from commit 41c0f89f5532ec110b927c3a67ceac83448c5d98)

llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
llvm/test/CodeGen/AArch64/arm64ec-hybrid-patchable.ll

index 310b152ef981735df2dbca7b1b6302f2fa9527c1..415edb189e60c4906eccc86392d5b1dd991fc48d 100644 (file)
@@ -833,6 +833,11 @@ bool AArch64Arm64ECCallLowering::runOnModule(Module &Mod) {
                                               "EXP+" + MangledName.value())));
       A->setAliasee(&F);
 
+      if (F.hasDLLExportStorageClass()) {
+        A->setDLLStorageClass(GlobalValue::DLLExportStorageClass);
+        F.setDLLStorageClass(GlobalValue::DefaultStorageClass);
+      }
+
       FnsMap[A] = GlobalAlias::create(GlobalValue::LinkOnceODRLinkage,
                                       MangledName.value(), &F);
       PatchableFns.insert(A);
index e5387d40b9c64a7e2d1190e871a99462da31a936..64fb5b36b2c6234cec4d93533e365e174fd44617 100644 (file)
@@ -238,7 +238,7 @@ define dso_local void @caller() nounwind {
 ; CHECK-NEXT:      .symidx exp
 ; CHECK-NEXT:      .word   0
 ; CHECK-NEXT:      .section        .drectve,"yni"
-; CHECK-NEXT:      .ascii  " /EXPORT:\"#exp$hp_target,EXPORTAS,exp$hp_target\""
+; CHECK-NEXT:      .ascii  " /EXPORT:exp"
 
 ; CHECK-NEXT:      .def    func;
 ; CHECK-NEXT:      .scl    2;