[llvm] [LoongArch] Avoid scheduling tls-desc code sequence in large code model (PR #121541)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 2 19:50:19 PST 2025
https://github.com/zhaoqi5 updated https://github.com/llvm/llvm-project/pull/121541
>From cc085f1adf7a2cca570b14c1226a841624c41fbe Mon Sep 17 00:00:00 2001
From: Qi Zhao <zhaoqi01 at loongson.cn>
Date: Thu, 2 Jan 2025 21:44:40 +0800
Subject: [PATCH 1/2] [LoongArch] Avoid scheduling tls-desc code sequence in
large code model
---
llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp | 10 +++++++++-
.../CodeGen/LoongArch/psabi-restricted-scheduling.ll | 2 +-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp b/llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
index 7d0e4f9d58a16d..4b142f43359d88 100644
--- a/llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
@@ -406,6 +406,11 @@ bool LoongArchInstrInfo::isSchedulingBoundary(const MachineInstr &MI,
// lu32i.d $a1, %ie64_pc_lo20(s)
// lu52i.d $a1, $a1, %ie64_pc_hi12(s)
//
+ // * pcalau12i $a0, %desc_pc_hi20(s)
+ // addi.d $a1, $zero, %desc_pc_lo12(s)
+ // lu32i.d $a1, %desc64_pc_lo20(s)
+ // lu52i.d $a1, $a1, %desc64_pc_hi12(s)
+ //
// For simplicity, only pcalau12i and lu52i.d are marked as scheduling
// boundaries, and the instructions between them are guaranteed to be
// ordered according to data dependencies.
@@ -430,12 +435,15 @@ bool LoongArchInstrInfo::isSchedulingBoundary(const MachineInstr &MI,
if (MO0 == LoongArchII::MO_IE_PC_HI && MO1 == LoongArchII::MO_IE_PC_LO &&
MO2 == LoongArchII::MO_IE_PC64_LO)
return true;
+ if (MO0 == LoongArchII::MO_DESC_PC_HI && MO1 == LoongArchII::MO_DESC_PC_LO &&
+ MO2 == LoongArchII::MO_DESC64_PC_LO)
+ return true;
break;
}
case LoongArch::LU52I_D: {
auto MO = MI.getOperand(2).getTargetFlags();
if (MO == LoongArchII::MO_PCREL64_HI || MO == LoongArchII::MO_GOT_PC64_HI ||
- MO == LoongArchII::MO_IE_PC64_HI)
+ MO == LoongArchII::MO_IE_PC64_HI || MO == LoongArchII::MO_DESC64_PC_HI)
return true;
break;
}
diff --git a/llvm/test/CodeGen/LoongArch/psabi-restricted-scheduling.ll b/llvm/test/CodeGen/LoongArch/psabi-restricted-scheduling.ll
index 1773b8e0149974..3390f7fe14ae67 100644
--- a/llvm/test/CodeGen/LoongArch/psabi-restricted-scheduling.ll
+++ b/llvm/test/CodeGen/LoongArch/psabi-restricted-scheduling.ll
@@ -252,8 +252,8 @@ define void @baz() nounwind {
; LARGEDESC_SCH: # %bb.0:
; LARGEDESC_SCH-NEXT: addi.d $sp, $sp, -16
; LARGEDESC_SCH-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
-; LARGEDESC_SCH-NEXT: addi.d $a1, $zero, %desc_pc_lo12(gd)
; LARGEDESC_SCH-NEXT: pcalau12i $a0, %desc_pc_hi20(gd)
+; LARGEDESC_SCH-NEXT: addi.d $a1, $zero, %desc_pc_lo12(gd)
; LARGEDESC_SCH-NEXT: lu32i.d $a1, %desc64_pc_lo20(gd)
; LARGEDESC_SCH-NEXT: lu52i.d $a1, $a1, %desc64_pc_hi12(gd)
; LARGEDESC_SCH-NEXT: add.d $a0, $a0, $a1
>From 07b1a4c67c70413b4439fe0b6ba3ddb0bf1c069b Mon Sep 17 00:00:00 2001
From: Qi Zhao <zhaoqi01 at loongson.cn>
Date: Fri, 3 Jan 2025 11:45:40 +0800
Subject: [PATCH 2/2] format
---
llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp b/llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
index 4b142f43359d88..54aeda28364003 100644
--- a/llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
@@ -435,7 +435,8 @@ bool LoongArchInstrInfo::isSchedulingBoundary(const MachineInstr &MI,
if (MO0 == LoongArchII::MO_IE_PC_HI && MO1 == LoongArchII::MO_IE_PC_LO &&
MO2 == LoongArchII::MO_IE_PC64_LO)
return true;
- if (MO0 == LoongArchII::MO_DESC_PC_HI && MO1 == LoongArchII::MO_DESC_PC_LO &&
+ if (MO0 == LoongArchII::MO_DESC_PC_HI &&
+ MO1 == LoongArchII::MO_DESC_PC_LO &&
MO2 == LoongArchII::MO_DESC64_PC_LO)
return true;
break;
More information about the llvm-commits
mailing list