diff options
author | Mingming Liu <mingmingl@google.com> | 2025-01-22 21:06:46 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-22 21:06:46 -0800 |
commit | de209fa11b5455155228bcdba012b6074388b917 (patch) | |
tree | 2bffdd7ea198a5505369b03835c41f864cbc1494 /llvm/lib/CodeGen/MachineFunction.cpp | |
parent | 163935a48df69bde944fae2b4581541dab30c730 (diff) | |
download | llvm-de209fa11b5455155228bcdba012b6074388b917.zip llvm-de209fa11b5455155228bcdba012b6074388b917.tar.gz llvm-de209fa11b5455155228bcdba012b6074388b917.tar.bz2 |
[CodeGen] Introduce Static Data Splitter pass (#122183)
https://discourse.llvm.org/t/rfc-profile-guided-static-data-partitioning/83744
proposes to partition static data sections.
This patch introduces a codegen pass. This patch produces jump table
hotness in the in-memory states (machine jump table info and entries).
Target-lowering and asm-printer consume the states and produce `.hot`
section suffix. The follow up PR
https://github.com/llvm/llvm-project/pull/122215 implements such
changes.
---------
Co-authored-by: Ellis Hoag <ellis.sparky.hoag@gmail.com>
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index b8dbe83..e482418 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -1311,6 +1311,10 @@ const unsigned MachineFunction::DebugOperandMemNumber = 1000000; // MachineJumpTableInfo implementation //===----------------------------------------------------------------------===// +MachineJumpTableEntry::MachineJumpTableEntry( + const std::vector<MachineBasicBlock *> &MBBs) + : MBBs(MBBs), Hotness(MachineFunctionDataHotness::Unknown) {} + /// Return the size of each entry in the jump table. unsigned MachineJumpTableInfo::getEntrySize(const DataLayout &TD) const { // The size of a jump table entry is 4 bytes unless the entry is just the @@ -1360,6 +1364,17 @@ unsigned MachineJumpTableInfo::createJumpTableIndex( return JumpTables.size()-1; } +bool MachineJumpTableInfo::updateJumpTableEntryHotness( + size_t JTI, MachineFunctionDataHotness Hotness) { + assert(JTI < JumpTables.size() && "Invalid JTI!"); + // Record the largest hotness value. + if (Hotness <= JumpTables[JTI].Hotness) + return false; + + JumpTables[JTI].Hotness = Hotness; + return true; +} + /// If Old is the target of any jump tables, update the jump tables to branch /// to New instead. bool MachineJumpTableInfo::ReplaceMBBInJumpTables(MachineBasicBlock *Old, |