Skip to content

[Clang][AArch64] Define __USER_LABEL_PREFIX__ to # for ARM64EC #78913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

bylaws
Copy link
Contributor

@bylaws bylaws commented Jan 21, 2024

This is required so that the linker knows that any symbols defined in assembly code are ARM64EC rather than X86_64.

CC: @cjacek

This is required so that the linker knows that any symbols defined in
assembly code are ARM64EC rather than X86_64.
@llvmbot llvmbot added clang Clang issues not falling into any other category backend:AArch64 clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jan 21, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 21, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-aarch64

Author: Billy Laws (bylaws)

Changes

This is required so that the linker knows that any symbols defined in assembly code are ARM64EC rather than X86_64.

CC: @cjacek


Full diff: https://github.com/llvm/llvm-project/pull/78913.diff

1 Files Affected:

  • (modified) clang/lib/Basic/Targets/AArch64.cpp (+6-4)
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index d47181bfca4fc86..4f57c30279a91fb 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1462,10 +1462,12 @@ WindowsARM64TargetInfo::WindowsARM64TargetInfo(const llvm::Triple &Triple,
 }
 
 void WindowsARM64TargetInfo::setDataLayout() {
-  resetDataLayout(Triple.isOSBinFormatMachO()
-                      ? "e-m:o-i64:64-i128:128-n32:64-S128"
-                      : "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128",
-                  Triple.isOSBinFormatMachO() ? "_" : "");
+  if (Triple.isOSBinFormatMachO()) {
+    resetDataLayout("e-m:o-i64:64-i128:128-n32:64-S128", "_");
+  } else {
+    resetDataLayout("e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128",
+                    Triple.isWindowsArm64EC() ? "#" : "");
+  }
 }
 
 TargetInfo::BuiltinVaListKind

: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128",
Triple.isOSBinFormatMachO() ? "_" : "");
if (Triple.isOSBinFormatMachO()) {
resetDataLayout("e-m:o-i64:64-i128:128-n32:64-S128", "_");
Copy link
Contributor

Choose a reason for hiding this comment

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

Weird, I wonder when Windows+AArch64+Mach-O is ever used... maybe @compnerd knows?

Copy link
Member

Choose a reason for hiding this comment

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

AFAIK Windows+MachO is used in some cases for JIT scenarios, because the runtime linking support in the JIT is much more complete for MachO than it is for PE/COFF.

@cjacek
Copy link
Contributor

cjacek commented Jan 22, 2024

Note that this prefix is expected on ARM64EC only for C function symbols. C++ symbols use a different mangling and data symbols are not decorated at all. This is different from other cases when __USER_LABEL_PREFIX__ is defined, I'm not sure.

@efriedma-quic
Copy link
Collaborator

I can sort of see how a define could be useful, but this doesn't match any existing usage of USER_LABEL_PREFIX given the relevant rules. I think reusing the name is more likely to cause confusion, rather than help anyone.

@bylaws
Copy link
Contributor Author

bylaws commented Jan 23, 2024

@efriedma-quic Fair enough, I found this cleaned up things on the compiler-rt side but even then it still needed changes to handle concatenating a #, and I'd imagine that to be the same for any other existing user. It would still be nice to have something equivalent to A64NAME for user code but that probably better fits in mingw.

@bylaws bylaws closed this Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AArch64 clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants