Page MenuHomePhabricator

[MSP430] Replace known epilogues with branches to __mspabi_func_epilog_N
Needs ReviewPublic

Authored by atrosinenko on Jul 23 2020, 5:22 AM.

Details

Summary

Optimize the size of epilogue sequences by replacing common cases with a single branch to __mspabi_func_epilog_<N> function described in MSP430 EABI document, part 3.8.

As part of that, the patch adjust handling of MSP430::Bi instruction.

Diff Detail

Event Timeline

atrosinenko created this revision.Jul 23 2020, 5:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2020, 5:22 AM
asl requested changes to this revision.Aug 7 2020, 2:52 AM

Will you please switch to iterators here?

Thanks!

llvm/lib/Target/MSP430/MSP430CommonEpilogueOptimizer.cpp
113

I would not use low-level list-manipulating stuff here. Can we just use iterators here?

So we would have iterator to Begin, to End. In the for loop do something like this:

while (EpilogueBegin != EpilogueEnd) {
      MachineInstr *InstrToRemove = EpilogueBegin;
      EpilogueBegin = std::next(EpilogueBegin);
      // Do crazy removal
}
127

See above. Please use iterators.

This revision now requires changes to proceed.Aug 7 2020, 2:52 AM

Address the comment + misc fixes.

Thanks!

atrosinenko added inline comments.Aug 7 2020, 6:36 AM
llvm/lib/Target/MSP430/MSP430CommonEpilogueOptimizer.cpp
156

Not sure this is not against the code style, still should work.

asl added inline comments.Aug 9 2020, 12:52 PM
llvm/lib/Target/MSP430/MSP430CommonEpilogueOptimizer.cpp
152

You don't need this. Just do std::next / std::prev prior to changing the iterators.

Address the review comment