This is an archive of the discontinued LLVM Phabricator instance.

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

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

arsenm added inline comments.Mar 30 2021, 6:26 PM
llvm/lib/Target/MSP430/MSP430CommonEpilogueOptimizer.cpp
146

getSubtarget<MSP430Subtarget>().getInstrInfo(() should work and is cleaner

llvm/lib/Target/MSP430/MSP430InstrInfo.cpp
187–193

This seems like a different patch. Also does AllowModify actually happen?

arsenm requested changes to this revision.Nov 16 2022, 3:51 PM

analyzeBranch should probably be a separate patch

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

can you use make_early_inc_range?

llvm/test/CodeGen/MSP430/mspabi-func-epilog-multi-terminators.mir
8–16

Can drop IR section

llvm/test/CodeGen/MSP430/mspabi-func-epilog-special-cases.ll
4

Move to -mtriple and drop datalayout

llvm/test/CodeGen/MSP430/mspabi-func-epilog.ll
8–9

Ditto

This revision now requires changes to proceed.Nov 16 2022, 3:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 16 2022, 3:51 PM