I have tested the register allocation in llvm, using: $llc -debug test.bc
where, test.c is like:
int a, b, c, d, x;
a = 3;
b = 5;
d = 4;
x = 100;
if ( a > b )
......
And I got the machine code before register allocation:
MOV32mi <fi#2>, 1, %reg0, 0, %reg0, 3; mem:ST4[%a]
MOV32mi <fi#3>, 1, %reg0, 0, %reg0, 5; mem:ST4[%b]
MOV32mi <fi#5>, 1, %reg0, 0, %reg0, 4; mem:ST4[%d]
MOV32mi <fi#6>, 1, %reg0, 0, %reg0, 100; mem:ST4[%x]
%reg16384<def> = MOV32rm <fi#3>, 1, %reg0, 0, %reg0;
mem:LD4[%b]
GR32:%reg16384
CMP32mr <fi#2>, 1, %reg0, 0, %reg0, %reg16384<kill>,
%EFLAGS<imp-def>; mem:LD4[%a] GR32:%reg16384
JLE_4 <BB#2>, %EFLAGS<imp-use,kill>
The machine code after register allocation:
MOV32mi <fi#2>, 1, %reg0, 0, %reg0, 3; mem:ST4[%a]
MOV32mi <fi#3>, 1, %reg0, 0, %reg0, 5; mem:ST4[%b]
MOV32mi <fi#5>, 1, %reg0, 0, %reg0, 4; mem:ST4[%d]
MOV32mi <fi#6>, 1, %reg0, 0, %reg0, 100; mem:ST4[%x]
%EAX<def> = MOV32rm <fi#3>, 1, %reg0, 0, %reg0;
mem:LD4[%b]Remembering SS#3 in physreg EAX
CMP32mr <fi#2>, 1, %reg0, 0, %reg0, %EAX<kill>,
%EFLAGS<imp-def>;
mem:LD4[%a]
JLE_4 <BB#2>, %EFLAGS<imp-use,kill>
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?
--
Best regards,
Li Qingan
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20110116/6389cd9a/attachment.html>