-
Notifications
You must be signed in to change notification settings - Fork 13.9k
[AArch64] Restrict .variant_pcs directive to ELF targets #140022
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
[AArch64] Restrict .variant_pcs directive to ELF targets #140022
Conversation
Directive was implemented in c87bd2d to support lazy binding and is emitted for vector PCS functions. It's specific to ELF but is currently emitted for all binary formats and crashing on non-ELF targets. Fixes llvm#138260 [1] https://github.com/ARM-software/abi-aa/blob/master/aaelf64/aaelf64.rst#st-other-values
@llvm/pr-subscribers-backend-aarch64 Author: Cullen Rhodes (c-rhodes) ChangesDirective was implemented in c87bd2d to support lazy binding and is emitted for vector PCS functions. It's specific to ELF but is currently emitted for all binary formats and crashing on non-ELF targets. Fixes #138260 [1] https://github.com/ARM-software/abi-aa/blob/master/aaelf64/aaelf64.rst#st-other-values Full diff: https://github.com/llvm/llvm-project/pull/140022.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index a53606851d0a2..f55b7ef7c20bb 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -1344,10 +1344,12 @@ AArch64AsmPrinter::getCodeViewJumpTableInfo(int JTI,
}
void AArch64AsmPrinter::emitFunctionEntryLabel() {
- if (MF->getFunction().getCallingConv() == CallingConv::AArch64_VectorCall ||
- MF->getFunction().getCallingConv() ==
- CallingConv::AArch64_SVE_VectorCall ||
- MF->getInfo<AArch64FunctionInfo>()->isSVECC()) {
+ const Triple &TT = TM.getTargetTriple();
+ if (TT.isOSBinFormatELF() &&
+ (MF->getFunction().getCallingConv() == CallingConv::AArch64_VectorCall ||
+ MF->getFunction().getCallingConv() ==
+ CallingConv::AArch64_SVE_VectorCall ||
+ MF->getInfo<AArch64FunctionInfo>()->isSVECC())) {
auto *TS =
static_cast<AArch64TargetStreamer *>(OutStreamer->getTargetStreamer());
TS->emitDirectiveVariantPCS(CurrentFnSym);
@@ -1355,8 +1357,7 @@ void AArch64AsmPrinter::emitFunctionEntryLabel() {
AsmPrinter::emitFunctionEntryLabel();
- if (TM.getTargetTriple().isWindowsArm64EC() &&
- !MF->getFunction().hasLocalLinkage()) {
+ if (TT.isWindowsArm64EC() && !MF->getFunction().hasLocalLinkage()) {
// For ARM64EC targets, a function definition's name is mangled differently
// from the normal symbol, emit required aliases here.
auto emitFunctionAlias = [&](MCSymbol *Src, MCSymbol *Dst) {
diff --git a/llvm/test/CodeGen/AArch64/variant-pcs.ll b/llvm/test/CodeGen/AArch64/variant-pcs.ll
index 49c504177358e..38510751fdd43 100644
--- a/llvm/test/CodeGen/AArch64/variant-pcs.ll
+++ b/llvm/test/CodeGen/AArch64/variant-pcs.ll
@@ -1,6 +1,13 @@
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -o - %s | FileCheck %s --check-prefix=CHECK-ASM --strict-whitespace
+; RUN: llc -mtriple=arm64-apple-macosx -mattr=+sve -o - %s | FileCheck %s --check-prefix=CHECK-ASM-NON-ELF-TARGET
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -filetype=obj -o - %s \
; RUN: | llvm-readobj --symbols - | FileCheck %s --check-prefix=CHECK-OBJ
+; RUN: llc -mtriple=arm64-apple-macosx -mattr=+sve -filetype=obj -o - %s \
+; RUN: | llvm-readobj --symbols - | FileCheck %s --check-prefix=CHECK-OBJ-NON-ELF-TARGET
+
+; .variant_pcs directive should only be emitted for ELF targets.
+; CHECK-ASM-NON-ELF-TARGET-NOT: .variant_pcs
+; CHECK-OBJ-NON-ELF-TARGET-NOT: Other [ (0x80)
define i32 @base_pcs() {
; CHECK-ASM-LABEL: base_pcs:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
; .variant_pcs directive should only be emitted for ELF targets. | ||
; CHECK-ASM-NON-ELF-TARGET-NOT: .variant_pcs | ||
; CHECK-OBJ-NON-ELF-TARGET-NOT: Other [ (0x80) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this check makes sense, because this seems ELF specific. You can just remove the | FileCheck %s --check-prefix=CHECK-OBJ-NON-ELF-TARGET
part of the RUN line, we just need to make sure it doesn't fail to compile.
I think this version of the fix is more correct than mine, so I'll take version this and add you as a co-author on my PR 👍 |
I've pushed your patch to #138924 (and addressed @sdesmalen-arm's nit). |
Directive was implemented in c87bd2d to support lazy binding and is emitted for vector PCS functions. It's specific to ELF but is currently emitted for all binary formats and crashing on non-ELF targets.
Fixes #138260