Skip to content

Commit 899c951

Browse files
committed
[AArch64] Null check TargetStreamer before emitting .variant_pcs
This was causing crashes on Mach-O targets as we don't construct a TargetStreamer for that object format. Other uses of the TargetStreamer (TS) appear to be limited to ELF and COFF platforms (where it is none null, so don't need changing).
1 parent 4b30b3f commit 899c951

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,8 @@ void AArch64AsmPrinter::emitFunctionEntryLabel() {
13721372
MF->getInfo<AArch64FunctionInfo>()->isSVECC()) {
13731373
auto *TS =
13741374
static_cast<AArch64TargetStreamer *>(OutStreamer->getTargetStreamer());
1375-
TS->emitDirectiveVariantPCS(CurrentFnSym);
1375+
if (TS)
1376+
TS->emitDirectiveVariantPCS(CurrentFnSym);
13761377
}
13771378

13781379
AsmPrinter::emitFunctionEntryLabel();

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)