[LLVMdev] FW: Unused argument registers can not be reused ?
Arnaud Allard de Grandmaison
Arnaud.AllardDeGrandMaison at dibcom.com
Thu Jun 3 13:01:03 PDT 2010
Oops. Forgot the mailing list in the reply.
--
Arnaud de Grandmaison
________________________________________
From: Arnaud Allard de Grandmaison
Sent: Thursday, June 03, 2010 9:57 PM
To: Jakob Stoklund Olesen
Subject: RE: [LLVMdev] Unused argument registers can not be reused ?
I have finally been able to make some progress : the bug has been introduced/revealed by svn commit #95493, which enabled DeadMachineInstructionElimPass for all targets.
Disabling this pass makes llvm-2.7 behave as expected.
What we can see when dumping the test function body at the path entry & exit is :
# Machine code for function test:
Function Live Ins: %R15W in reg%1024, %R14W in reg%1025, %R13W in reg%1026, %R12W in reg%1027
BB#0: derived from LLVM BB %entry
Live Ins: %R15W %R14W %R13W %R12W
%reg1027<def> = MOV16rr %R12W
%reg1026<def> = MOV16rr %R13W
%reg1025<def> = MOV16rr %R14W
%reg1024<def> = MOV16rr %R15W
%reg1028<def> = MOV16rm %reg0, <ga:@b>; mem:LD2[@b]
%reg1029<def> = ADD16rm %reg1028, %reg0, <ga:@a>, %SRW<imp-def,dead>; mem:LD2[@a]
SUB16mr %reg0, <ga:@r>, %reg1029, %SRW<imp-def,dead>; mem:ST2[@r] LD2[@r]
RET
# End machine code for function test.
# Machine code for function test:
Function Live Ins: %R15W in reg%1024, %R14W in reg%1025, %R13W in reg%1026, %R12W in reg%1027
BB#0: derived from LLVM BB %entry
Live Ins: %R15W %R14W %R13W %R12W
%reg1028<def> = MOV16rm %reg0, <ga:@b>; mem:LD2[@b]
%reg1029<def> = ADD16rm %reg1028, %reg0, <ga:@a>, %SRW<imp-def,dead>; mem:LD2[@a]
SUB16mr %reg0, <ga:@r>, %reg1029, %SRW<imp-def,dead>; mem:ST2[@r] LD2[@r]
RET
# End machine code for function test.
This points to 2 different ways of fixing the issue :
1- Fix the backends to not lower unused arguments, or at least, not mark them as liveins --- if possible.
2- Fix the pass
I will fill a bug tomorrow for this tomorrow.
Best regards,
--
Arnaud de Grandmaison
________________________________________
From: Jakob Stoklund Olesen [stoklund at 2pi.dk]
Sent: Thursday, June 03, 2010 7:39 PM
To: Arnaud Allard de Grandmaison
Cc: llvmdev at cs.uiuc.edu
Subject: Re: [LLVMdev] Unused argument registers can not be reused ?
On Jun 3, 2010, at 6:33 AM, Arnaud Allard de Grandmaison wrote:
> While migrating my codebase from llvm-2.6 to llvm-2.7, I found a different behaviour in the register allocation. I have been able to reproduce it using the msp430 backend, with the 2.7 release as well as the svn head.
>
> For the msp430, the first four parameters of a function are passed thru registers. What I observe is that if those parameters are not used inside the function, those registers can not be used.
It looks like you found a bug, R12-R15 should be usable inside the function.
Please file a PR against the code generator.
I think that unused arguments shouldn't have been marked live in at all.
Thanks,
/jakob
More information about the llvm-dev
mailing list