During the execution of long functions or functions that have a lot of inlined code could come to the situation where variable's value could be transferred from one register to another. Also some variables values could be moved from subreg to reg by the ABI, like on the figure 1. In that situation we have variable's value in two registers. First location could be lost at some moment but second location will probably be used at some point and we could use that location to get this variable's value. This patch adds support for tracking such second location. The transfer is recognized only if destination register is callee saved register.
renamable $s4_64 = SLL64_32 renamable $s2, implicit killed $s2_64 ... %s4_64<def> = or64 %s2_64<kill>, %zero_64 -------------------------------------------------------------------------------- Figure 1: Transferring register values from s2 to s4 with killing s2
Since I do not have small test example I will insert here part of MachineInstruction stream that I have been working on:
BB#3: derived from LLVM BB %if.end4 Live Ins: %GP_64 %S0_64 %S1_64 %S3_64 %S4_64 %S5_64 %S7_64 Predecessors according to CFG: BB#1 BB#2 ... DBG_VALUE %S1_64, %noreg, !"tid", <!606>; line no:81 %S6_64<def> = SLL64_32 %S1, %S1_64<imp-use,kill>; dbg:singlefunction.c:141:6 <-- copy like instruction ... %A0_64<def> = OR64 %S0_64, %ZERO_64; dbg:singlefunction.c:141:6 %A1_64<def> = OR64 %S6_64, %ZERO_64; dbg:singlefunction.c:141:6 <- tid is indeed second argument of the following function call JALR64Pseudo %T9_64, <regmask ... %S1_64 %S2_64 %S3_64 %S4_64 %S5_64 %S6_64 %S7_64>, ... ; dbg:singlefunction.c:141:6 * %A2_64<def> = OR64 %S7_64, %ZERO_64; dbg:singlefunction.c:141:6 %S1_64<def> = OR64 %V0_64, %ZERO_64; dbg:singlefunction.c:141:6 DBG_VALUE %S6_64, %noreg, !"tid", <!606>; line no:81 <-- This DBG_VALUE is feature of this patch DBG_VALUE %S1_64, %noreg, !"child_oid_cur", <!606>; line no:134 %V0<def> = LW %FP_64, 8292; mem:LD4[%cur_local_err](tbaa=!616)(dereferenceable) dbg:singlefunction.c:144:6 DBG_VALUE %V0, %noreg, !"cur_local_err", <!606>; line no:87 BEQ %V0, %ZERO, <BB#6>, %AT<imp-def>; dbg:singlefunction.c:144:6 * NOP; dbg:singlefunction.c:144:6 Successors according to CFG: BB#6 BB#4
Just double-checking: 0 is always an invalid register number?