[llvm] cc5d8a4 - [AArch64] fall back to SDAG for instructions with emulated TLS variables (#129215)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 1 07:47:29 PST 2025
Author: Sebastian Schaller
Date: 2025-03-01T15:47:25Z
New Revision: cc5d8a4b2fc765c3c432f1ad0b185dae518d41bd
URL: https://github.com/llvm/llvm-project/commit/cc5d8a4b2fc765c3c432f1ad0b185dae518d41bd
DIFF: https://github.com/llvm/llvm-project/commit/cc5d8a4b2fc765c3c432f1ad0b185dae518d41bd.diff
LOG: [AArch64] fall back to SDAG for instructions with emulated TLS variables (#129215)
Fixes #126200
At the moment, GlobalISel is missing an implementation for emulated TLS
variables.
I fixed the issue by falling back to SDAG in this case, as I currently
don't have the knowledge to implement it myself.
Co-authored-by: Schaller, Sebastian <sebastian.schaller at dentsplysirona.com>
Added:
llvm/test/CodeGen/AArch64/GlobalISel/emutls-fallback.ll
Modified:
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index 467094e9befef..1cc7480e44eae 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -2960,8 +2960,12 @@ bool AArch64InstructionSelector::select(MachineInstr &I) {
assert(OpFlags == AArch64II::MO_GOT);
} else {
GV = I.getOperand(1).getGlobal();
- if (GV->isThreadLocal())
+ if (GV->isThreadLocal()) {
+ // We don't support instructions with emulated TLS variables yet
+ if (TM.useEmulatedTLS())
+ return false;
return selectTLSGlobalValue(I, MRI);
+ }
OpFlags = STI.ClassifyGlobalReference(GV, TM);
}
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/emutls-fallback.ll b/llvm/test/CodeGen/AArch64/GlobalISel/emutls-fallback.ll
new file mode 100644
index 0000000000000..e90b3e2d05afa
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/emutls-fallback.ll
@@ -0,0 +1,29 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc -emulated-tls -mtriple aarch64-apple-darwin -global-isel -global-isel-abort=2 %s -o - 2>&1 | FileCheck %s
+
+; This file checks that the fallback path for instructions with emulated TLS variables to selection dag works.
+
+; CHECK: warning: Instruction selection used fallback path for main
+
+ at x = thread_local global i32 42, align 4
+
+define i32 @main(i32 %argc, ptr %argv) {
+; CHECK-LABEL: main:
+; CHECK: ; %bb.0: ; %entry
+; CHECK-NEXT: stp x29, x30, [sp, #-16]! ; 16-byte Folded Spill
+; CHECK-NEXT: .cfi_def_cfa_offset 16
+; CHECK-NEXT: .cfi_offset w30, -8
+; CHECK-NEXT: .cfi_offset w29, -16
+; CHECK-NEXT: Lloh0:
+; CHECK-NEXT: adrp x0, ___emutls_v.x at PAGE
+; CHECK-NEXT: Lloh1:
+; CHECK-NEXT: add x0, x0, ___emutls_v.x at PAGEOFF
+; CHECK-NEXT: bl ___emutls_get_address
+; CHECK-NEXT: ldr w0, [x0]
+; CHECK-NEXT: ldp x29, x30, [sp], #16 ; 16-byte Folded Reload
+; CHECK-NEXT: ret
+; CHECK-NEXT: .loh AdrpAdd Lloh0, Lloh1
+entry:
+ %0 = load i32, ptr @x, align 4
+ ret i32 %0
+}
More information about the llvm-commits
mailing list