[PATCH] D139996: [RISCV] Disable callee-saved register when the register is written by llvm.write_register intrinsic

Zixuan Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 15 21:53:55 PST 2022


zixuan-wu added a comment.

In D139996#4000175 <https://reviews.llvm.org/D139996#4000175>, @jrtc27 wrote:

> (If the register is marked reserved with -ffixed-xN then you won't get the save/restore code here)

Nope, it's not enough. Before this patch, for example

  struct global_data {};
  register struct global_data *x9 asm ("x9");
  
  void arch_setup_gd(struct global_data *gd_ptr)
  {
          x9 = gd_ptr;
  
  }
  
  clang register.c -O2 -ffixed-x9 -S -o -
  
  arch_setup_gd:                          # @arch_setup_gd
  # %bb.0:                                # %entry
  	addi	sp, sp, -16
  	sd	s1, 8(sp)                       # 8-byte Folded Spill
  	mv	s1, a0
  	ld	s1, 8(sp)                       # 8-byte Folded Reload
  	addi	sp, sp, 16
  	ret




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139996



More information about the llvm-commits mailing list