[PATCH] D42600: [CodeGen][Shrink-wrap]split restore point

Sushant Gokhale via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 27 00:21:10 PDT 2023


sushgokh added a comment.

@nathanchance Thanks for the initiative. Could you please apply the below patch on top of existing patch and check?

  --- a/llvm/lib/CodeGen/ShrinkWrap.cpp
  +++ b/llvm/lib/CodeGen/ShrinkWrap.cpp
  @@ -471,7 +471,9 @@ tryToSplitRestore(MachineBasicBlock *MBB,
         MBBFallthrough.insert(BB);
  
     MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock();
  -  MF->insert(MachineFunction::iterator(MBB), NMBB);
  +  // Insert this block at the end of the function. Inserting in between may
  +  // interfere with control flow optimizer decisions.
  +  MF->insert(MF->end(), NMBB);
  
     for (const MachineBasicBlock::RegisterMaskPair &LI : MBB->liveins())
       NMBB->addLiveIn(LI.PhysReg);
  @@ -577,6 +579,12 @@ bool ShrinkWrap::postShrinkWrapping(bool HasCandidate, MachineFunction &MF,
         !MPDT->dominates(InitRestore, InitSave))
       return false;
  
  +  // Bail out of the optimization if any of the basic block is target of
  +  // INLINEASM_BR instruction
  +  for (MachineBasicBlock &MBB : MF)
  +    if (MBB.isInlineAsmBrIndirectTarget())
  +      return false;
  +
     DenseSet<const MachineBasicBlock *> DirtyBBs;
     for (MachineBasicBlock &MBB : MF) {
       if (MBB.isEHPad()) {


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D42600/new/

https://reviews.llvm.org/D42600



More information about the llvm-commits mailing list