From 37ffd63402aa7d8e957486c8453286fb0069cf95 Mon Sep 17 00:00:00 2001 From: xiajingze Date: Mon, 15 Sep 2025 10:20:56 +0800 Subject: [PATCH] [AArch64] Mark MOVbaseTLS as having side effects This is a problem found in BRPC, in which MOVbaseTLS is optimized in machine licm and cse, and make the result wrong. To fix this issue, MOVbaseTLS is marked as having side effect and licm/cse will not touch this register. --- llvm/lib/Target/AArch64/AArch64InstrInfo.td | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td index 8adceb9ffd15..5e83e47d68b4 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td @@ -1609,6 +1609,7 @@ def : Pat<(AArch64mrs imm:$id), // The thread pointer (on Linux, at least, where this has been implemented) is // TPIDR_EL0. +let hasSideEffects = 1 in def MOVbaseTLS : Pseudo<(outs GPR64:$dst), (ins), [(set GPR64:$dst, AArch64threadpointer)]>, Sched<[WriteSys]>; -- Gitee