This is an archive of the discontinued LLVM Phabricator instance.

[NFC] Fix invalid iterator dereferencing in MachineLoop::getBottomBlock
Needs ReviewPublic

Authored by kachkov98 on Oct 21 2022, 2:32 AM.

Details

Reviewers
fhahn
Summary

If bottom block of the loop is the last basic block in function,
dereferencing of end() iterator can occur (and for other basic
blocks the condition is always false); fix typo in this check.

Diff Detail

Event Timeline

kachkov98 created this revision.Oct 21 2022, 2:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2022, 2:32 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
kachkov98 requested review of this revision.Oct 21 2022, 2:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2022, 2:32 AM
fhahn added a subscriber: fhahn.Oct 21 2022, 2:34 AM

Could you add a test case for the issue?

NFC because for now this method is not used by any LLVM pass; this looks like a typo of some old code refactoring (MachineLoop::getTopBlock is correct BTW)

Could you add a test case for the issue?

Sure, I'll add unit test for this method.

kachkov98 updated this revision to Diff 469536.Oct 21 2022, 3:45 AM

Add unit test

kachkov98 edited reviewers, added: fhahn; removed: Florian.Oct 23 2022, 1:59 AM

Ping (not critical for upstream because this method is never used, but we are using it in downstream compiler)