Page MenuHomePhabricator

[ARM][MachineOutliner] Add stack fixup feature.
ClosedPublic

Authored by yroux on Dec 9 2020, 4:46 AM.

Details

Summary

This patch handles cases where we have to save/restore the link register into the stack and and load/store instruction which use the stack are part of the outlined region. It checks that there will be no overflow introduced by the new offset and fixup these instructions accordingly.

Diff Detail

Event Timeline

yroux created this revision.Dec 9 2020, 4:46 AM
yroux requested review of this revision.Dec 9 2020, 4:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2020, 4:46 AM

Sorry for the big delay Yvan, I haven't really been working on LLVM recently.

llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
5954

How about extracting this out into ARMBaseInstrInfo? There seems to be a fair number of places in the backend where getting the NumBits and Scale comes up.

6431

Does this mean that we can call fixupPostOutline twice on MBB? I'm confused why we're checking for saving LR here, when it looks like we'd know for sure around line 6351.

yroux added a comment.Jan 18 2021, 5:30 AM

Hi Sam,

no worries ;)

llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
5954

Yes I was thinking of that kind of refactoring and I'll look at it, now if you are ok with that peace of code, what about committing it as it is such that we can have full version of the machine outliner in LLVM-12. And I'll propose a refactoring patch ASAP (since will touch BaseRegisterInfo, ConstantIsland, etc... I guess it will take some time to validate it properly)

6431

we have 2 cases where LR is saved on the stack and we need to fixup its access:

  • when we have a call inside the outlined region, we are saving/restoring LR at the begining/end of this block, it is the case handled at line 6351
  • but also, at call site when LR is read after the outlined region of one of the candidates for instance (this is the MachineOutlinerDefault mode) we have to fixup the stack access as well (this case)
samparker accepted this revision.Jan 18 2021, 6:46 AM

LGTM

llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
5954

Okay, sounds fair enough to me.

This revision is now accepted and ready to land.Jan 18 2021, 6:46 AM
This revision was landed with ongoing or failed builds.Jan 19 2021, 1:59 AM
This revision was automatically updated to reflect the committed changes.