_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
llc -march=x86 -regalloc=gc tst.bc gcc -m32 tst.sMy machine is a 64-bit machine. Maybe you are working with a different architecture and that's why it worked for you?
Well, now I can't reproduce what I thought I had before (an example that works fine with your code except when using that flag). I do have a small example that works fine with *my* code except when using that flag. I've attached the source (.c), the assembly that my code produces w/o using the "verify" flag (.s), the output of trying to create assembly *with* the "verify" flag (.out), and the .bc file used as input to my register allocator. If you can identify a problem by looking at these files, that would be great!
I can supply my register allocator if you'd like to have it, but it involves a number of (longish) files.
Thanks for any insights you can provide on this!
Susan
On 11/15/2012 06:45 PM, Lang Hames wrote:
Hi Susan,
To my knowledge the verifier doesn't produce false positives with any of
the in-tree allocators. If it is raising an error that is worth
investigating. Is it raising an error on any simple test cases? Can you
share the failing case?
- Lang.
On Thu, Nov 15, 2012 at 2:44 PM, Susan Horwitz <hor...@cs.wisc.edu<mailto:hor...@cs.wisc.edu>> wrote:
I tried using this flag and it gave me errors on code that otherwise
assembles and runs just fine (using the version of Gcra.cpp that
Lang wrote). So I'm wondering if I should really be using the flag?
I'm using it like this:
llc -verify-machineinstrs -load Debug/lib/P4.so -regalloc=gc xxx.bc
Susan
On 11/15/2012 01:13 PM, Jakob Stoklund Olesen wrote:
On Nov 15, 2012, at 7:53 AM, Susan Horwitz<hor...@cs.wisc.edu
<mailto:hor...@cs.wisc.edu>>
RBP is used as the frame pointer on x86 (hence its automatic appearance in your code), and shouldn't be allocated to any vreg in function bar. Loading/saving RBP should be managed by the stack frame setup/teardown code.
If it doesn't already, your allocator should filter out reserved registers (See MachineRegisterInfo::isReserved(unsigned preg)) when assigning physregs.
ArrayRef<MCPhysReg> pregs = TRC->getRawAllocationOrder(&MF);for (int i = 0; i < pregs.size(); ++i) {
� if (MRI->isReserved(pregs[i]))� � continue;� // use preg...}
You could also use the AllocationOrder class to simplify the task of finding valid pregs, though it does require you to use VirtRegMap.�
If you are already checking the reserved regs then I've misdiagnosed the problem. I'd be happy to dig further if you can point me to a copy of your allocator and a test case.
Cheers,Lang.
On Thu, Nov 29, 2012 at 3:49 PM, Susan Horwitz <hor...@cs.wisc.edu> wrote:
I have a new problem: Register RBP is used in a function foo. �(I am not allocating RBP to any virtual register, the instances of RBP in function foo are in the machine code when my register allocator starts.)
Function foo calls function bar. �Register RBP is not saved across the call, though it is live after the call. �Function bar includes a virtual register. �The code that I'm using to find the registers available to be allocated to that virtual register includes EBP in that available-preg set. �This is a disaster, since writing into EBP clobbers RBP.
I tried to add code to save all live physical registers across calls, but I don't know how to get the appropriate TargetRegisterClass (needed to call CreateSpillStackObject).
Is there a different way to save/restore RBP across calls? �Or a way to get its TargetRegisterClass?
Susan
I AM filtering out reserved registers.On 11/30/2012 6:36 PM, Lang Hames wrote:
RBP is used as the frame pointer on x86 (hence its automatic appearance in your code), and shouldn't be allocated to any vreg in function bar. Loading/saving RBP should be managed by the stack frame setup/teardown code.If it doesn't already, your allocator should filter out reserved registers (See MachineRegisterInfo::isReserved(unsigned preg)) when assigning physregs.
I am not allocating RBP in function bar, I am allocating EBP, because it is NOT in the list of reserved registers for function bar.
Neither register RBP nor register EBP is saved/restored across the call from foo to bar, either by the code for the call or the code for entry to bar.
The input C file that is causing this problem is flex.c (attached). The calling function is "yyparse" and the called function is "scinstal".
Here are the reserved registers for yyparse: { 7 44 54 106 111 114 118 }
Here are the reserved registers for scinstal: { 54 111 114 }
Register EBP is preg 44, which is NOT in the reserved list for scinstal (nor is it an alias of any of those reserved registers; the aliases are { 50 64 117 118 }). I don;t know which preg corresponds to RBP.
You say that RBP should be saved/restored across the call. I tried to generate that code, but, as I said in my previous mail, I don't know how to get the appropriate TargetRegisterClass (needed to call CreateSpillStackObject). Should I instead be generating code to save register EBP at the start of scinstal, restoring it at the end of that function?
Susan
ArrayRef<MCPhysReg> pregs = TRC->getRawAllocationOrder(&MF);for (int i = 0; i < pregs.size(); ++i) {
if (MRI->isReserved(pregs[i]))
continue;
// use preg...}
You could also use the AllocationOrder class to simplify the task of finding valid pregs, though it does require you to use VirtRegMap.
If you are already checking the reserved regs then I've misdiagnosed the problem. I'd be happy to dig further if you can point me to a copy of your allocator and a test case.
Cheers,Lang.
On Thu, Nov 29, 2012 at 3:49 PM, Susan Horwitz <hor...@cs.wisc.edu> wrote:
I have a new problem: Register RBP is used in a function foo. (I am not allocating RBP to any virtual register, the instances of RBP in function foo are in the machine code when my register allocator starts.)
Function foo calls function bar. Register RBP is not saved across the call, though it is live after the call. Function bar includes a virtual register. The code that I'm using to find the registers available to be allocated to that virtual register includes EBP in that available-preg set. This is a disaster, since writing into EBP clobbers RBP.
I tried to add code to save all live physical registers across calls, but I don't know how to get the appropriate TargetRegisterClass (needed to call CreateSpillStackObject).
Is there a different way to save/restore RBP across calls? Or a way to get its TargetRegisterClass?
Susan