This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] fix the endless loop of --iterative-guess
ClosedPublic

Authored by maipianworni on Jul 10 2023, 11:21 PM.

Details

Summary

Solve the endless loop caused by iterative guess. The main function of this option is guessEdgeByIterativeApproach, where the do while loop involves guessPredEdgeCounts and guessSuccessEdgeCounts. In some scenarios, the do while loop will fall into an endless loop. The reason is that although the GuessedPredEdgeCounts function has guessed the pred-edges counts, GuessedArcs does not insert the corresponding BB block, resulting in the changed variable always being true.

Diff Detail

Event Timeline

maipianworni created this revision.Jul 10 2023, 11:21 PM
Herald added a reviewer: Amir. · View Herald Transcript
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: ayermolo. · View Herald Transcript
maipianworni requested review of this revision.Jul 10 2023, 11:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 10 2023, 11:21 PM

Thanks for fixing this. We do need context for the diff and a test case.

maipianworni retitled this revision from The endless loop of --iterative-guess to [BOLT] fix the endless loop of --iterative-guess.Jul 12 2023, 1:39 AM
hzq added a subscriber: hzq.Jul 13 2023, 8:12 PM
rafauler accepted this revision.Jul 31 2023, 3:02 PM

Thanks for the context, the fix looks good to me. Unfortunately, we can't check in the test as is because we can't guarantee the .fdata file will always make sense -- we would typically write this test in assembly language to guarantee offsets remain the same.

It's fine to commit this without the test as the fix is pretty clear now.

This revision is now accepted and ready to land.Jul 31 2023, 3:02 PM
Allen added a subscriber: Allen.Jul 31 2023, 8:43 PM
This revision was automatically updated to reflect the committed changes.