[PATCH] D62190: [RISCV] Allow shrink wrapping for RISC-V

Shiva Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 12 23:35:02 PDT 2019


shiva0217 added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVFrameLowering.cpp:230
+  MachineBasicBlock::iterator MBBI = MBB.getFirstTerminator();
+  if (MBBI == MBB.end())
+    MBBI = MBB.getLastNonDebugInstr();
----------------
apazos wrote:
> I have been verifying the pending patches at Oz, Os, and also O2. This is helping with uncovering issues. 
> You can run it with 'llc test.ll  -enable-shrink-wrap
> 
> With the latest standalone patch, it seems we have a few crashes left. Below is a bugpoint reduced test:
> 
> define dso_local void @test() local_unnamed_addr {
> entry:
>   br i1 undef, label %T.exit, label %for.body.i
> 
> for.body.i:                                       ; preds = %for.body.i, %entry
>   store i32 0, i32* undef
>   %incdec.ptr.i.i = getelementptr inbounds i32, i32* null, i32 1
>   %cmp.i.i = icmp eq i32* undef, undef
>   br i1 %cmp.i.i, label %T.exit.loopexit, label %for.body.i
> 
> T.exit.loopexit: ; preds = %for.body.i
>   %0 = ptrtoint i32* %incdec.ptr.i.i to i32
>   br label %T.exit
> 
> T.exit: ; preds = %T.exit.loopexit, %entry
>   ret void
> }
> 
> 
It seems that shrink wrapping may choose an empty basic block to insert epilogue. We might need to add empty block detection for DL initialization and MBBI advance. Something like: 
  DebugLoc DL = !MBB.empty() ? MBBI->getDebugLoc() : DebugLoc();
  if (!MBB.empty() && !MBBI->isTerminator())
     MBBI = std::next(MBBI);


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62190





More information about the llvm-commits mailing list