Skip to content

Commit 575e68e

Browse files
committed
FunctionSpecialization: Make the ordering of BestSpecs stricter
otherwise it's not guaranteed which of two candidates with the same score would get specialized first, or at all.
1 parent 0e346ee commit 575e68e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llvm/lib/Transforms/IPO/FunctionSpecialization.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,9 @@ bool FunctionSpecializer::run() {
689689
// specialization budget, which is derived from maximum number of
690690
// specializations per specialization candidate function.
691691
auto CompareScore = [&AllSpecs](unsigned I, unsigned J) {
692-
return AllSpecs[I].Score > AllSpecs[J].Score;
692+
if (AllSpecs[I].Score != AllSpecs[J].Score)
693+
return AllSpecs[I].Score > AllSpecs[J].Score;
694+
return I > J;
693695
};
694696
const unsigned NSpecs =
695697
std::min(NumCandidates * MaxClones, unsigned(AllSpecs.size()));

0 commit comments

Comments
 (0)