[PATCH] D46232: [SystemZ, IPRA] determineCalleeSaves must always add return register and DP.

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 30 07:58:25 PDT 2018


jonpa added a comment.

> I do not believe we need to do anything special with r11. This is only special if it is used as frame pointer, in which case the code before already adds it as caller-saved:
> 
> if (HasFP)
>  SavedRegs.set(SystemZ::R11D);

I reran ipra-03.ll with saving r11 commented out, and got this debug output:

  ++++++++++++++++++++ Register Usage Information Propagation ++++++++++++++++++++
  MachineFunction : fun0
   -------------------- Register Usage Information Collector Pass --------------------
  Function Name : fun0
  Clobbered Registers: fun0 function optimized for not having CSR.
  $cc $r0d $r1d $r2d $r3d $r11d $r12d $r13d $r14d $r15d $r1h $r2h $r13h $r14h $r15h $r0l $r1l $r2l $r3l $r11l $r12l $r13l $r14l $r15l $r0q $r2q $r10q $r12q $r14q
  ----------------------------------------
   ++++++++++++++++++++ Register Usage Information Propagation ++++++++++++++++++++
  MachineFunction : BZ2_blockSort
  Call Instruction Before Register Usage Info Propagation :
  CallBRASL @fun0, $r2d, $r3d, $r4d, $r5d, $r6d, <regmask $f8d $f9d $f10d $f11d $f12d $f13d $f14d $f15d $f8q $f9q $f12q $f13q $f8s $f9s $f10s $f11s $f12s $f13s $f14s $f15s $r6d $r7d $r8d $r9d \
  $r10d $r11d $r12d $r13d $r14d $r15d $r6h $r7h $r8h $r9h $r10h $r11h $r12h $r13h $r14h $r15h $r6l $r7l $r8l $r9l $r10l $r11l $r12l $r13l $r14l $r15l $r6q $r8q $r10q $r12q $r14q>, implicit-def\
   dead $r14d, implicit-def dead $cc, implicit-def $r2d
  
  Call Instruction After Register Usage Info Propagation : CallBRASL @fun0, $r2d, $r3d, $r4d, $r5d, $r6d, <regmask $noreg $a0 $a1 $a2 $a3 $a4 $a5 $a6 $a7 $a8 $a9 $a10 $a11 $a12 $a13 $a14 $a15 \
  $c0 $c1 $c2 $c3 $c4 $c5 $c6 $c7 $c8 $c9 $c10 $c11 $c12 $c13 $c14 $c15 $v0 $v1 $v2 $v3 $v4 $v5 $v6 $v7 $v8 $v9 $v10 $v11 $v12 $v13 $v14 $v15 $v16 $v17 $v18 $v19 $v20 $v21 $v22 $v23 $v24 $v25 \
  $v26 $v27 $v28 $v29 $v30 $v31 $f0d $f1d $f2d $f3d $f4d $f5d $f6d $f7d $f8d $f9d $f10d $f11d $f12d $f13d $f14d $f15d $f16d $f17d $f18d $f19d $f20d $f21d $f22d $f23d $f24d $f25d $f26d $f27d $f\
  28d $f29d $f30d $f31d $f0q $f1q $f4q $f5q $f8q $f9q $f12q $f13q $f0s $f1s $f2s $f3s $f4s $f5s $f6s $f7s $f8s $f9s $f10s $f11s $f12s $f13s $f14s $f15s $f16s $f17s $f18s $f19s $f20s $f21s $f22\
  s $f23s $f24s $f25s $f26s $f27s $f28s $f29s $f30s $f31s $r4d $r5d $r6d $r7d $r8d $r9d $r10d $r0h $r3h $r4h $r5h $r6h $r7h $r8h $r9h $r10h $r11h $r12h $r4l $r5l $r6l $r7l $r8l $r9l $r10l $r4q\
   $r6q $r8q>, implicit-def dead $r14d, implicit-def dead $cc, implicit-def $r2d

fun0 uses %r11l, so Collector adds %r11l and %r11d. Propagation then updates the regmask on the call to fun0 to clobber those registers.

I am a bit unsure about what would happen with %r11 in the calling function if hasFP() returns true. In that case %r11 is a reserved register in that function, so regalloc will not try to use it. In the top of Propagate, I see

  /// This updated RegMask will be used by the register allocator while allocating
  /// the current MachineFunction.

It doesn't say here that it will save a reserved register around a call that clobbers it. Generally, I would fear that a reserved register is under the responsibility of the Target, but maybe I am missing something here? (I assume that's why we have to add it in determineCalleeSaves ourselves if HasFP is true?)


https://reviews.llvm.org/D46232





More information about the llvm-commits mailing list