Skip to content

Commit 3aaf44f

Browse files
MacDuec-rhodes
andauthored
[AArch64] Restrict .variant_pcs directive to ELF targets (#138924)
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 --------- Co-authored-by: Cullen Rhodes <cullen.rhodes@arm.com>
1 parent 858649a commit 3aaf44f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -filetype=obj -o - %s \
33
; RUN: | llvm-readobj --symbols - | FileCheck %s --check-prefix=CHECK-OBJ
44

5+
; Check we don't crash when using a Mach-O object format.
6+
; RUN: llc -mtriple=arm64-apple-macosx15.0.0 -mattr=+sve -filetype=obj -o /dev/null %s
7+
58
define i32 @base_pcs() {
69
; CHECK-ASM-LABEL: base_pcs:
710
; CHECK-ASM-NOT: .variant_pcs

0 commit comments

Comments
 (0)