<div>I have tested the register allocation in llvm, using: $llc -debug test.bc</div><div>where, test.c is like:</div><div><br></div><div>        int a, b, c, d, x;</div><div>        a = 3;</div><div>        b = 5;</div><div>
        d = 4;</div><div>        x = 100;</div><div>        if ( a > b ) </div><div>        ......</div><div><br></div><div> And I got the machine code before register allocation:</div><div>  </div><div>        MOV32mi <fi#2>, 1, %reg0, 0, %reg0, 3; mem:ST4[%a]</div>
<div>        MOV32mi <fi#3>, 1, %reg0, 0, %reg0, 5; mem:ST4[%b]</div><div>        MOV32mi <fi#5>, 1, %reg0, 0, %reg0, 4; mem:ST4[%d]</div><div>        MOV32mi <fi#6>, 1, %reg0, 0, %reg0, 100; mem:ST4[%x]</div>
<div>        %reg16384<def> = MOV32rm <fi#3>, 1, %reg0, 0, %reg0; mem:LD4[%b] GR32:%reg16384</div><div>        CMP32mr <fi#2>, 1, %reg0, 0, %reg0, %reg16384<kill>, %EFLAGS<imp-def>; mem:LD4[%a] GR32:%reg16384</div>
<div>        JLE_4 <BB#2>, %EFLAGS<imp-use,kill></div><div><br></div><div> The machine code after register allocation:</div><div><br></div><div>        MOV32mi <fi#2>, 1, %reg0, 0, %reg0, 3; mem:ST4[%a]</div>
<div>        MOV32mi <fi#3>, 1, %reg0, 0, %reg0, 5; mem:ST4[%b]</div><div>        MOV32mi <fi#5>, 1, %reg0, 0, %reg0, 4; mem:ST4[%d]</div><div>        MOV32mi <fi#6>, 1, %reg0, 0, %reg0, 100; mem:ST4[%x]</div>
<div>        %EAX<def> = MOV32rm <fi#3>, 1, %reg0, 0, %reg0; mem:LD4[%b]Remembering SS#3 in physreg EAX</div><div>        CMP32mr <fi#2>, 1, %reg0, 0, %reg0, %EAX<kill>, %EFLAGS<imp-def>; mem:LD4[%a]</div>
<div>        JLE_4 <BB#2>, %EFLAGS<imp-use,kill></div><div><br></div><div> It seems only variables named "reg<num>" are allocated into registers. My problem is, why not allocate the local variables "a", "b", .etc into registers instead of into stack frame? Is there any problem for allocating "a" into register file rather than stack frame with offset of 2? </div>
<div><br></div><div><br></div><br>-- <br>Best regards,<div><br></div><div>Li Qingan</div><br>