Skip to content

Commit 7ca78bd

Browse files
c-rhodesMacDue
authored andcommitted
Restrict .variant_pcs directive to ELF targets
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 [1] https://github.com/ARM-software/abi-aa/blob/master/aaelf64/aaelf64.rst#st-other-values
1 parent d1cd5b4 commit 7ca78bd

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,19 +1344,20 @@ AArch64AsmPrinter::getCodeViewJumpTableInfo(int JTI,
13441344
}
13451345

13461346
void AArch64AsmPrinter::emitFunctionEntryLabel() {
1347-
if (MF->getFunction().getCallingConv() == CallingConv::AArch64_VectorCall ||
1348-
MF->getFunction().getCallingConv() ==
1349-
CallingConv::AArch64_SVE_VectorCall ||
1350-
MF->getInfo<AArch64FunctionInfo>()->isSVECC()) {
1347+
const Triple &TT = TM.getTargetTriple();
1348+
if (TT.isOSBinFormatELF() &&
1349+
(MF->getFunction().getCallingConv() == CallingConv::AArch64_VectorCall ||
1350+
MF->getFunction().getCallingConv() ==
1351+
CallingConv::AArch64_SVE_VectorCall ||
1352+
MF->getInfo<AArch64FunctionInfo>()->isSVECC())) {
13511353
auto *TS =
13521354
static_cast<AArch64TargetStreamer *>(OutStreamer->getTargetStreamer());
13531355
TS->emitDirectiveVariantPCS(CurrentFnSym);
13541356
}
13551357

13561358
AsmPrinter::emitFunctionEntryLabel();
13571359

1358-
if (TM.getTargetTriple().isWindowsArm64EC() &&
1359-
!MF->getFunction().hasLocalLinkage()) {
1360+
if (TT.isWindowsArm64EC() && !MF->getFunction().hasLocalLinkage()) {
13601361
// For ARM64EC targets, a function definition's name is mangled differently
13611362
// from the normal symbol, emit required aliases here.
13621363
auto emitFunctionAlias = [&](MCSymbol *Src, MCSymbol *Dst) {

llvm/test/CodeGen/AArch64/variant-pcs.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -o - %s | FileCheck %s --check-prefix=CHECK-ASM --strict-whitespace
2+
; RUN: llc -mtriple=arm64-apple-macosx -mattr=+sve -o - %s | FileCheck %s --check-prefix=CHECK-ASM-NON-ELF-TARGET
23
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -filetype=obj -o - %s \
34
; RUN: | llvm-readobj --symbols - | FileCheck %s --check-prefix=CHECK-OBJ
5+
; RUN: llc -mtriple=arm64-apple-macosx -mattr=+sve -filetype=obj -o - %s \
6+
; RUN: | llvm-readobj --symbols - | FileCheck %s --check-prefix=CHECK-OBJ-NON-ELF-TARGET
7+
8+
; .variant_pcs directive should only be emitted for ELF targets.
9+
; CHECK-ASM-NON-ELF-TARGET-NOT: .variant_pcs
10+
; CHECK-OBJ-NON-ELF-TARGET-NOT: Other [ (0x80)
411

512
; Check we don't crash when using a Mach-O object format.
613
; RUN: llc -mtriple=arm64-apple-macosx15.0.0 -mattr=+sve -filetype=obj -o /dev/null %s

0 commit comments

Comments
 (0)