[llvm] [AArch64] Make IFUNC opt-in rather than opt-out. (PR #171648)
Harald van Dijk via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 11 08:36:46 PST 2025
https://github.com/hvdijk updated https://github.com/llvm/llvm-project/pull/171648
>From d9f5db5357210a8adc9e46f1fbd9d66d8ca05cb3 Mon Sep 17 00:00:00 2001
From: Harald van Dijk <hdijk at accesssoftek.com>
Date: Thu, 11 Dec 2025 16:35:30 +0000
Subject: [PATCH] [AArch64] Make IFUNC opt-in rather than opt-out.
IFUNCs require loader support, so for arbitrary environments, the safe
assumption is to assume that they are not supported.
In particular, aarch64-linux-pauthtest may be used with musl, and was
wrongly detected as supporting IFUNCs.
---
llvm/include/llvm/TargetParser/Triple.h | 2 +-
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 8 +++-----
llvm/test/CodeGen/AArch64/ptrauth-reloc.ll | 16 ++++++++--------
3 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
index 9480e7b36dc2c..b9fbe2b02e22c 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -769,7 +769,7 @@ class Triple {
bool isOSGlibc() const {
return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
getOS() == Triple::Hurd) &&
- !isAndroid() && !isMusl();
+ !isAndroid() && !isMusl() && getEnvironment() != Triple::PAuthTest;
}
/// Tests whether the OS is AIX.
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index 87256352faccd..8c5e90e1a6b06 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -2438,11 +2438,9 @@ static bool targetSupportsIRelativeRelocation(const Triple &TT) {
if (!TT.isOSBinFormatELF())
return false;
- // musl doesn't support IFUNCs.
- if (TT.isMusl())
- return false;
-
- return true;
+ // IFUNCs are supported on glibc, bionic, and some but not all of the BSDs.
+ return TT.isOSGlibc() || TT.isAndroid() || TT.isOSFreeBSD() ||
+ TT.isOSDragonFly() || TT.isOSNetBSD();
}
// Emit an ifunc resolver that returns a signed pointer to the specified target,
diff --git a/llvm/test/CodeGen/AArch64/ptrauth-reloc.ll b/llvm/test/CodeGen/AArch64/ptrauth-reloc.ll
index f2d080644e93e..b546fe4ed8279 100644
--- a/llvm/test/CodeGen/AArch64/ptrauth-reloc.ll
+++ b/llvm/test/CodeGen/AArch64/ptrauth-reloc.ll
@@ -4,13 +4,13 @@
; RUN: llc < ok.ll -mtriple arm64e-apple-darwin \
; RUN: | FileCheck %s --check-prefix=CHECK-MACHO
-; RUN: llc < ok.ll -mtriple aarch64-elf -mattr=+pauth \
+; RUN: llc < ok.ll -mtriple aarch64-android -mattr=+pauth \
; RUN: | FileCheck %s --check-prefix=CHECK-ELF
; RUN: llc < ok.ll -mtriple arm64e-apple-darwin \
; RUN: -global-isel -verify-machineinstrs -global-isel-abort=1 \
; RUN: | FileCheck %s --check-prefix=CHECK-MACHO
-; RUN: llc < ok.ll -mtriple aarch64-elf -mattr=+pauth \
+; RUN: llc < ok.ll -mtriple aarch64-android -mattr=+pauth \
; RUN: -global-isel -verify-machineinstrs -global-isel-abort=1 \
; RUN: | FileCheck %s --check-prefix=CHECK-ELF
@@ -141,13 +141,13 @@
; RUN: not llc < err-key.ll -mtriple arm64e-apple-darwin 2>&1 \
; RUN: | FileCheck %s --check-prefix=CHECK-ERR-KEY
-; RUN: not llc < err-key.ll -mtriple aarch64-elf -mattr=+pauth 2>&1 \
+; RUN: not llc < err-key.ll -mtriple aarch64-android -mattr=+pauth 2>&1 \
; RUN: | FileCheck %s --check-prefix=CHECK-ERR-KEY
; RUN: not llc < err-key.ll -mtriple arm64e-apple-darwin \
; RUN: -global-isel -verify-machineinstrs -global-isel-abort=1 2>&1 \
; RUN: | FileCheck %s --check-prefix=CHECK-ERR-KEY
-; RUN: not llc < err-key.ll -mtriple aarch64-elf -mattr=+pauth \
+; RUN: not llc < err-key.ll -mtriple aarch64-android -mattr=+pauth \
; RUN: -global-isel -verify-machineinstrs -global-isel-abort=1 2>&1 \
; RUN: | FileCheck %s --check-prefix=CHECK-ERR-KEY
@@ -161,13 +161,13 @@
; RUN: not llc < err-disc.ll -mtriple arm64e-apple-darwin 2>&1 \
; RUN: | FileCheck %s --check-prefix=CHECK-ERR-DISC
-; RUN: not llc < err-disc.ll -mtriple aarch64-elf -mattr=+pauth 2>&1 \
+; RUN: not llc < err-disc.ll -mtriple aarch64-android -mattr=+pauth 2>&1 \
; RUN: | FileCheck %s --check-prefix=CHECK-ERR-DISC
; RUN: not llc < err-disc.ll -mtriple arm64e-apple-darwin \
; RUN: -global-isel -verify-machineinstrs -global-isel-abort=1 2>&1 \
; RUN: | FileCheck %s --check-prefix=CHECK-ERR-DISC
-; RUN: not llc < err-disc.ll -mtriple aarch64-elf -mattr=+pauth \
+; RUN: not llc < err-disc.ll -mtriple aarch64-android -mattr=+pauth \
; RUN: -global-isel -verify-machineinstrs -global-isel-abort=1 2>&1 \
; RUN: | FileCheck %s --check-prefix=CHECK-ERR-DISC
@@ -178,9 +178,9 @@
;--- err-disc-elf.ll
-; RUN: not llc < err-disc-elf.ll -mtriple aarch64-elf -mattr=+pauth 2>&1 \
+; RUN: not llc < err-disc-elf.ll -mtriple aarch64-android -mattr=+pauth 2>&1 \
; RUN: | FileCheck %s --check-prefix=CHECK-ERR-DISC-ELF
-; RUN: not llc < err-disc-elf.ll -mtriple aarch64-elf -mattr=+pauth \
+; RUN: not llc < err-disc-elf.ll -mtriple aarch64-android -mattr=+pauth \
; RUN: -global-isel -verify-machineinstrs -global-isel-abort=1 2>&1 \
; RUN: | FileCheck %s --check-prefix=CHECK-ERR-DISC-ELF
More information about the llvm-commits
mailing list