This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Avoid RegScavenger::forward in AArch64SpeculationHardening
ClosedPublic

Authored by foad on May 15 2023, 5:25 AM.

Details

Summary

RegScavenger::backward is preferred because it does not rely on accurate
kill flags.

Diff Detail

Event Timeline

foad created this revision.May 15 2023, 5:25 AM
foad requested review of this revision.May 15 2023, 5:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 15 2023, 5:25 AM
foad added inline comments.
llvm/lib/Target/AArch64/AArch64SpeculationHardening.cpp
299–302

It is unfortunate that RegScavenger::backward(MachineBasicBlock::iterator) does not provide a way to step back to the state right at the start of the MBB.

arsenm added inline comments.May 16 2023, 12:22 PM
llvm/lib/Target/AArch64/AArch64SpeculationHardening.cpp
299–302

Would it help to use reverse_iterator? When I first looked into doing this I think I got hung up on making reverse_iterator work just as well

foad added inline comments.May 17 2023, 1:48 AM
llvm/lib/Target/AArch64/AArch64SpeculationHardening.cpp
299–302

I don't think using reverse_iterator in AArch64SpeculationHardening would help. Did you mean also changing the RegScavenger API to take reverse_iterators? That might make sense, I'm not sure.

I think a proper fix would change both the RegScavenger API and the internals to track liveness into *MBBI instead of out of it. But I don't want to change any of that yet. The API lets me do what I need, just in an ugly way.

arsenm accepted this revision.May 23 2023, 12:51 AM
arsenm added inline comments.
llvm/lib/Target/AArch64/AArch64SpeculationHardening.cpp
299–302

Yes, I think I had a full set of reverse_iterator APIs but it wasn't particularly usable with everything else expecting forward iterators

This revision is now accepted and ready to land.May 23 2023, 12:51 AM
barannikov88 added inline comments.
llvm/lib/Target/AArch64/AArch64SpeculationHardening.cpp
299–302

FWIW A reverse iterator can be converted to a normal iterator with I.getReverse().

This revision was landed with ongoing or failed builds.May 23 2023, 1:32 AM
This revision was automatically updated to reflect the committed changes.