-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AArch64AsmPrinter]Place jump tables into hot/unlikely-prefixed data sections for aarch64 #126018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AArch64AsmPrinter]Place jump tables into hot/unlikely-prefixed data sections for aarch64 #126018
Conversation
cc @Colibrow |
@llvm/pr-subscribers-backend-aarch64 Author: Mingming Liu (mingmingl-llvm) ChangesThis is a follow-up patch of #125993 to port jump table partitions for aarch64. Full diff: https://github.com/llvm/llvm-project/pull/126018.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index c92c203f247954..0593c1cd2b14d2 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -1280,10 +1280,18 @@ void AArch64AsmPrinter::emitJumpTableImpl(const MachineJumpTableInfo &MJTI,
if (JumpTableIndices.empty())
return;
const TargetLoweringObjectFile &TLOF = getObjFileLowering();
- MCSection *ReadOnlySec = TLOF.getSectionForJumpTable(MF->getFunction(), TM);
+ const auto &F = MF->getFunction();
+ const std::vector<MachineJumpTableEntry> &JT = MJTI.getJumpTables();
+
+ MCSection *ReadOnlySec = nullptr;
+ if (TM.Options.EnableStaticDataPartitioning) {
+ ReadOnlySec =
+ TLOF.getSectionForJumpTable(F, TM, &JT[JumpTableIndices.front()]);
+ } else {
+ ReadOnlySec = TLOF.getSectionForJumpTable(F, TM);
+ }
OutStreamer->switchSection(ReadOnlySec);
- const std::vector<MachineJumpTableEntry> &JT = MJTI.getJumpTables();
auto AFI = MF->getInfo<AArch64FunctionInfo>();
for (unsigned JTI : JumpTableIndices) {
const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
diff --git a/llvm/test/CodeGen/AArch64/jump-table-partition.ll b/llvm/test/CodeGen/AArch64/jump-table-partition.ll
index e0525d0384a978..d282c366578d70 100644
--- a/llvm/test/CodeGen/AArch64/jump-table-partition.ll
+++ b/llvm/test/CodeGen/AArch64/jump-table-partition.ll
@@ -35,16 +35,17 @@
; RUN: -aarch64-enable-atomic-cfg-tidy=false -aarch64-min-jump-table-entries=2 \
; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=FUNCLESS,JT
-; A function's section prefix is used for all jump tables of this function.
-; @foo is hot so its jump table data section has a hot prefix.
-; NUM: .section .rodata.hot.,"a",@progbits,unique,2
+; In function @foo, the 2 switch instructions to jt0.* and jt1.* are placed in
+; hot-prefixed sections, and the 2 switch instructions to jt2.* and jt3.* are
+; placed in cold-prefixed sections.
+; NUM: .section .rodata.hot.,"a",@progbits,unique,2
; FUNC: .section .rodata.hot.foo,"a",@progbits
; FUNCLESS: .section .rodata.hot.,"a",@progbits
; JT: .LJTI0_0:
; JT: .LJTI0_2:
-; NUM: .section .rodata.hot.,"a",@progbits,unique,3
-; FUNC-NOT: .section .rodata.hot.foo
-; FUNCLESS-NOT: .section .rodata.hot.,"a",@progbits
+; NUM: .section .rodata.unlikely.,"a",@progbits,unique,3
+; FUNC: .section .rodata.unlikely.foo,
+; FUNCLESS: .section .rodata.unlikely.,"a",@progbits
; JT: .LJTI0_1:
; JT: .LJTI0_3:
|
Co-authored-by: Ellis Hoag <[email protected]>
Hi folks, a reminder about this change when you have a moment :) thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…e for jump table partitions on aarch64 (#125993) With 3feb724, AsmPrinter can place jump table entries into `.hot` or `.unlikely` prefixed data sections. This change refactors AsmPrinter and AArch64AsmPrinter to prepare for the aarch64 port. * Before this patch, the AsmPrinter class exposes `emitJumpTableInfo` as a virtual method, and AArch64AsmPrinter overrides `emitJumpTableInfo` for jump table emission. * After this patch, both AsmPrinter and AArch64AsmPrinter shares `AsmPrinter::emitJumpTableInfo`, and class-specific code are moved inside each class's `emitJumpTableImpl` respectively. This is a follow-up of #125987, and #126018 implements the port for aarch64.
Sorry for the spam! I forgot the change the base branch after merging the main branch. |
…r to prepare for jump table partitions on aarch64 (#125993) With llvm/llvm-project@3feb724, AsmPrinter can place jump table entries into `.hot` or `.unlikely` prefixed data sections. This change refactors AsmPrinter and AArch64AsmPrinter to prepare for the aarch64 port. * Before this patch, the AsmPrinter class exposes `emitJumpTableInfo` as a virtual method, and AArch64AsmPrinter overrides `emitJumpTableInfo` for jump table emission. * After this patch, both AsmPrinter and AArch64AsmPrinter shares `AsmPrinter::emitJumpTableInfo`, and class-specific code are moved inside each class's `emitJumpTableImpl` respectively. This is a follow-up of llvm/llvm-project#125987, and llvm/llvm-project#126018 implements the port for aarch64.
…e for jump table partitions on aarch64 (llvm#125993) With llvm@3feb724, AsmPrinter can place jump table entries into `.hot` or `.unlikely` prefixed data sections. This change refactors AsmPrinter and AArch64AsmPrinter to prepare for the aarch64 port. * Before this patch, the AsmPrinter class exposes `emitJumpTableInfo` as a virtual method, and AArch64AsmPrinter overrides `emitJumpTableInfo` for jump table emission. * After this patch, both AsmPrinter and AArch64AsmPrinter shares `AsmPrinter::emitJumpTableInfo`, and class-specific code are moved inside each class's `emitJumpTableImpl` respectively. This is a follow-up of llvm#125987, and llvm#126018 implements the port for aarch64.
…sections for aarch64 (llvm#126018) This is a follow-up patch of llvm#125993 to port jump table partitions for aarch64. --------- Co-authored-by: Ellis Hoag <[email protected]>
This is a follow-up patch of #125993 to port jump table partitions for aarch64.