@@ -2881,42 +2881,41 @@ void AsmPrinter::emitJumpTableInfo() {
2881
2881
MJTI->getEntryKind () == MachineJumpTableInfo::EK_LabelDifference64,
2882
2882
F);
2883
2883
2884
+ std::vector<unsigned > JumpTableIndices;
2885
+ for (unsigned JTI = 0 , JTSize = JT.size (); JTI != JTSize; ++JTI)
2886
+ JumpTableIndices.push_back (JTI);
2884
2887
if (!EmitStaticDataHotnessSuffix) {
2885
- std::vector<unsigned > JumpTableIndices;
2886
- for (unsigned JTI = 0 , e = JT.size (); JTI != e; ++JTI)
2887
- JumpTableIndices.push_back (JTI);
2888
- // Prior code in this function verifies JT is not empty. Use JT[0] directly.
2889
2888
emitJumpTables (JumpTableIndices, TLOF.getSectionForJumpTable (F, TM),
2890
2889
JTInDiffSection, *MJTI);
2891
2890
return ;
2892
2891
}
2893
2892
2894
- // Iterate all jump tables, put them into two vectors, hot and lukewarm
2895
- std::vector<unsigned > HotOrWarmJumpTableIndices, ColdJumpTableIndices;
2896
-
2897
- for (unsigned JTI = 0 , e = JT.size (); JTI != e; ++JTI) {
2898
- if (JT[JTI].Hotness == llvm::DataHotness::Cold)
2899
- ColdJumpTableIndices.push_back (JTI);
2900
- else
2901
- HotOrWarmJumpTableIndices.push_back (JTI);
2893
+ // Iterate all jump tables, put hot jump table indices towards the beginning
2894
+ // of the vector, and cold jump table indices towards the end.
2895
+ unsigned ColdJumpTableStart = JT.size ();
2896
+ for (unsigned JTI = 0 ; JTI != ColdJumpTableStart;) {
2897
+ if (JT[JTI].Hotness == llvm::DataHotness::Cold) {
2898
+ ColdJumpTableStart -= 1 ;
2899
+ std::swap (JumpTableIndices[JTI], JumpTableIndices[ColdJumpTableStart]);
2900
+ } else
2901
+ JTI += 1 ;
2902
2902
}
2903
2903
2904
- if (!HotOrWarmJumpTableIndices.empty ())
2905
- emitJumpTables (HotOrWarmJumpTableIndices,
2906
- TLOF.getSectionForJumpTable (
2907
- F, TM, &JT[*HotOrWarmJumpTableIndices.begin ()]),
2908
- JTInDiffSection, *MJTI);
2904
+ if (ColdJumpTableStart != 0 )
2905
+ emitJumpTables (
2906
+ ArrayRef<unsigned >(JumpTableIndices).slice (0 , ColdJumpTableStart),
2907
+ TLOF.getSectionForJumpTable (F, TM, &JT[0 ]), JTInDiffSection, *MJTI);
2909
2908
2910
- if (!ColdJumpTableIndices. empty ())
2909
+ if (ColdJumpTableStart != JT. size ())
2911
2910
emitJumpTables (
2912
- ColdJumpTableIndices ,
2913
- TLOF.getSectionForJumpTable (F, TM, &JT[*ColdJumpTableIndices. begin () ]),
2911
+ ArrayRef< unsigned >(JumpTableIndices). slice (ColdJumpTableStart) ,
2912
+ TLOF.getSectionForJumpTable (F, TM, &JT[ColdJumpTableStart ]),
2914
2913
JTInDiffSection, *MJTI);
2915
2914
2916
2915
return ;
2917
2916
}
2918
2917
2919
- void AsmPrinter::emitJumpTables (const std::vector <unsigned > & JumpTableIndices,
2918
+ void AsmPrinter::emitJumpTables (ArrayRef <unsigned > JumpTableIndices,
2920
2919
MCSection *JumpTableSection,
2921
2920
bool JTInDiffSection,
2922
2921
const MachineJumpTableInfo &MJTI) {
0 commit comments