Skip to content

Commit 027ae56

Browse files
resolve review feedback
1 parent ea2d838 commit 027ae56

File tree

2 files changed

+11
-37
lines changed

2 files changed

+11
-37
lines changed

llvm/include/llvm/CodeGen/AsmPrinter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,9 +893,8 @@ class AsmPrinter : public MachineFunctionPass {
893893
// Internal Implementation Details
894894
//===------------------------------------------------------------------===//
895895

896-
template <typename Iterator>
897896
void emitJumpTableImpl(const MachineJumpTableInfo &MJTI,
898-
const llvm::iterator_range<Iterator> &JumpTableIndices,
897+
ArrayRef<unsigned> JumpTableIndices,
899898
bool JTInDiffSection);
900899
void emitJumpTableEntry(const MachineJumpTableInfo &MJTI,
901900
const MachineBasicBlock *MBB, unsigned uid) const;

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2868,59 +2868,34 @@ void AsmPrinter::emitJumpTableInfo() {
28682868
MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference64,
28692869
F);
28702870

2871-
std::vector<unsigned> JumpTableIndices;
28722871
if (!TM.Options.EnableStaticDataPartitioning) {
2872+
SmallVector<unsigned> JumpTableIndices;
28732873
for (unsigned JTI = 0, JTSize = JT.size(); JTI < JTSize; ++JTI)
28742874
JumpTableIndices.push_back(JTI);
2875-
emitJumpTableImpl(
2876-
*MJTI,
2877-
llvm::make_range(JumpTableIndices.begin(), JumpTableIndices.end()),
2878-
JTInDiffSection);
2875+
emitJumpTableImpl(*MJTI, JumpTableIndices, JTInDiffSection);
28792876
return;
28802877
}
28812878

2879+
SmallVector<unsigned> HotJumpTableIndices, ColdJumpTableIndices;
28822880
// When static data partitioning is enabled, collect jump table entries that
28832881
// go into the same section together to reduce the amount of section switch
28842882
// statements.
2885-
//
2886-
// Iterate all jump tables, put hot jump table indices towards the beginning
2887-
// of the vector, and cold jump table indices towards the end. Meanwhile
2888-
// retain the relative orders of original jump tables.
2889-
int NumHotJumpTables = 0, NextColdJumpTableIndex = JT.size() - 1;
2890-
JumpTableIndices.resize(JT.size());
28912883
for (unsigned JTI = 0, JTSize = JT.size(); JTI < JTSize; ++JTI) {
28922884
if (JT[JTI].Hotness == MachineFunctionDataHotness::Cold) {
2893-
JumpTableIndices[NextColdJumpTableIndex--] = JTI;
2885+
ColdJumpTableIndices.push_back(JTI);
28942886
} else {
2895-
JumpTableIndices[NumHotJumpTables++] = JTI;
2887+
HotJumpTableIndices.push_back(JTI);
28962888
}
28972889
}
28982890

2899-
emitJumpTableImpl(
2900-
*MJTI,
2901-
llvm::make_range(JumpTableIndices.begin(),
2902-
JumpTableIndices.begin() + NumHotJumpTables),
2903-
2904-
JTInDiffSection);
2905-
2906-
const int NumColdJumpTables = JT.size() - NumHotJumpTables;
2907-
assert(NumColdJumpTables >= 0 && "Invalid number of cold jump tables.");
2908-
2909-
// Reverse iterating cold jump table indices to emit in the original order.
2910-
emitJumpTableImpl(
2911-
*MJTI,
2912-
llvm::make_range(JumpTableIndices.rbegin(),
2913-
JumpTableIndices.rbegin() + NumColdJumpTables),
2914-
JTInDiffSection);
2915-
2891+
emitJumpTableImpl(*MJTI, HotJumpTableIndices, JTInDiffSection);
2892+
emitJumpTableImpl(*MJTI, ColdJumpTableIndices, JTInDiffSection);
29162893
return;
29172894
}
29182895

2919-
template <typename Iterator>
2920-
void AsmPrinter::emitJumpTableImpl(
2921-
const MachineJumpTableInfo &MJTI,
2922-
const llvm::iterator_range<Iterator> &JumpTableIndices,
2923-
bool JTInDiffSection) {
2896+
void AsmPrinter::emitJumpTableImpl(const MachineJumpTableInfo &MJTI,
2897+
ArrayRef<unsigned> JumpTableIndices,
2898+
bool JTInDiffSection) {
29242899
if (JumpTableIndices.empty())
29252900
return;
29262901

0 commit comments

Comments
 (0)