[PATCH] D123180: [RISCV] Fixing stack offset for RVV object with vararg in stack.

Roger Ferrer Ibanez via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 7 04:27:48 PDT 2022


rogfer01 accepted this revision.
rogfer01 added a comment.
This revision is now accepted and ready to land.

This looks good to me, based on what we discussed on D123179 <https://reviews.llvm.org/D123179> with this change the stack looks like this

F22705926: Screenshot from 2022-04-07 13-01-55.png <https://reviews.llvm.org/F22705926>

The assembly emitted is as follows, the offset of `v8` is now correctly computed.

  asm_fprintf:                            # @asm_fprintf
  # %bb.0:                                # %entry
  	addi	sp, sp, -64
  	sd	ra, 40(sp)                      # 8-byte Folded Spill
  	sd	s0, 32(sp)                      # 8-byte Folded Spill
  	sd	s1, 24(sp)                      # 8-byte Folded Spill
  	csrr	a0, vlenb
  	sub	sp, sp, a0
  	mv	s0, a4
  	mv	s1, a1
  	csrr	a0, vlenb
  	add	a0, sp, a0
  	sd	a7, 56(a0)
  	csrr	a0, vlenb
  	add	a0, sp, a0
  	sd	a6, 48(a0)
  	vsetivli	zero, 2, e8, mf8, ta, mu
  	vmv.v.i	v8, 0
  	addi	a0, sp, 24
  	vs1r.v	v8, (a0)                        # Unknown-size Folded Spill
  .LBB0_1:                                # %while.cond
                                          # =>This Inner Loop Header: Depth=1
  	bnez	zero, .LBB0_1
  # %bb.2:                                # %sw.bb
                                          #   in Loop: Header=BB0_1 Depth=1
  	vsetivli	zero, 2, e8, mf8, ta, mu
  	addi	a0, sp, 24
  	vl1r.v	v8, (a0)                        # Unknown-size Folded Reload
  	vse8.v	v8, (s0)
  	mv	a0, s1
  	call	fprintf at plt
  	j	.LBB0_1

I've also checked cases with FP and BP but they seem unaffected by the original bug.

I have no objection with this change. Thanks @kito-cheng.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123180



More information about the llvm-commits mailing list