This is an archive of the discontinued LLVM Phabricator instance.

[NFC][LoopCacheAnalysis] Use stable_sort() to avoid non-deterministic print output
ClosedPublic

Authored by congzhe on Apr 30 2022, 7:47 PM.

Details

Summary

As per discussion in https://reviews.llvm.org/D122857#3483861, https://reviews.llvm.org/D122857#3483912,
the print output of loop cache analysis sometimes has a non-deterministic order (and therefore we have been using CHECK-DAG in its lit tests).

This patch changes the sorting of LoopCosts to llvm::stable_sort() where we compare loop cost numbers and sort the loops. In case of the same loop cost numbers, llvm::stable_sort() now would output a deterministic loop order.

Comments on this patch are appreciated :)

Diff Detail

Event Timeline

congzhe created this revision.Apr 30 2022, 7:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 30 2022, 7:47 PM
congzhe requested review of this revision.Apr 30 2022, 7:47 PM
Meinersbur accepted this revision.May 1 2022, 12:27 AM

LGTM.

Making output deterministic is always a worthwhile goal.

This revision is now accepted and ready to land.May 1 2022, 12:27 AM
fhahn accepted this revision.May 1 2022, 2:33 AM

LGTM, thanks!

llvm/include/llvm/Analysis/LoopCacheAnalysis.h
245–246

nit: there should be no need to use llvm:: as this is already in the llvm namespace.

congzhe updated this revision to Diff 426325.EditedMay 1 2022, 8:52 PM

Thanks for the review! Addressed Florian's comment, will land it shortly.

This revision was landed with ongoing or failed builds.May 1 2022, 9:55 PM
This revision was automatically updated to reflect the committed changes.