This is an archive of the discontinued LLVM Phabricator instance.

CodeGen: Avoid dereferencing end() in MachineScheduler
ClosedPublic

Authored by dexonsmith on Aug 11 2016, 9:07 AM.

Details

Reviewers
MatzeB
Summary

Check MachineInstr::isDebugValue for the same instruction as we're
calling isSchedBoundary, avoiding the possibility of dereferencing
end().

It's possible that instead the loop here should check for I==RegionEnd
and continue to use I->isDebugValue() (instead of std::prev(I)), but I
doubt it.

This is trigged by a huge number of tests, but they happen to magically
pass right now. I found this because WIP patches for PR26753 convert
them into crashes.

Diff Detail

Event Timeline

dexonsmith updated this revision to Diff 67693.Aug 11 2016, 9:07 AM
dexonsmith retitled this revision from to CodeGen: Avoid dereferencing end() in MachineScheduler.
dexonsmith updated this object.
dexonsmith added a reviewer: MatzeB.
dexonsmith added a subscriber: llvm-commits.
MatzeB accepted this revision.Aug 11 2016, 10:52 AM
MatzeB edited edge metadata.

The change looks correct, as DebugValues should never be scheduling barriers I don't expect any differences in the compute NumRegionInstrs either.
LGTM.

This revision is now accepted and ready to land.Aug 11 2016, 10:52 AM
dexonsmith closed this revision.Aug 14 2016, 5:32 PM

Thanks for the review! I committed this (but forgot to respond here until now) in r278394.