diff --git a/bolt/lib/Passes/BinaryPasses.cpp b/bolt/lib/Passes/BinaryPasses.cpp --- a/bolt/lib/Passes/BinaryPasses.cpp +++ b/bolt/lib/Passes/BinaryPasses.cpp @@ -1211,8 +1211,7 @@ continue; } - if (!UseColdSection || Function.hasValidIndex() || - Function.hasValidProfile()) + if (!UseColdSection || Function.hasValidIndex()) Function.setCodeSectionName(BC.getMainCodeSectionName()); else Function.setCodeSectionName(BC.getColdCodeSectionName()); diff --git a/bolt/lib/Passes/ReorderFunctions.cpp b/bolt/lib/Passes/ReorderFunctions.cpp --- a/bolt/lib/Passes/ReorderFunctions.cpp +++ b/bolt/lib/Passes/ReorderFunctions.cpp @@ -128,6 +128,13 @@ } } + // Assign valid index for functions with valid profile. + for (auto &It : BFs) { + BinaryFunction &BF = It.second; + if (!BF.hasValidIndex() && BF.hasValidProfile()) + BF.setIndex(Index++); + } + if (opts::ReorderFunctions == RT_NONE) return;