LLVM is assuming this: struct InstrSlots { enum { LOAD = 0, USE = 1, DEF = 2, STORE = 3, NUM = 4 }; So VNI->def is always modulo 2. For coalescing, it's checking if the RHS is live at the "use" cycle. So it's checking VNI->def-1. Evan On Sep 25, 2007, at 8:55 AM, David Greene wrote:> On Tuesday 25 September 2007 10:49, David Greene wrote: >> I've hit a bug in a refactored version of coalescing and I'm >> trying to >> understand what is going on. In particular, I'm curious about this >> line in SimpleRegisterCoalescing.cpp: >> >> 00710 LHSValsDefinedFromRHS[VNI] >> RHS.getLiveRangeContaining(VNI->def-1)->valno; >> >> Why VNI->def-1? The bug I'm seeing is that RHS returns a NULL >> LiveRange because it doesn't contain VNI->def-1: >> >> %reg1093,0 = [5750,5754:2)[5754,5782:1)[5782,5858:0)[5868,5870:0) >> 0 at 5782-(5858 5870) 1 at 5754-(5778) 2 at 5750 > > I should aff that VNI->def is 5750 which is in the interval. > > -Dave > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On Tuesday 25 September 2007 12:25, Evan Cheng wrote:> LLVM is assuming this: > struct InstrSlots { > enum { > LOAD = 0, > USE = 1, > DEF = 2, > STORE = 3, > NUM = 4 > }; > > So VNI->def is always modulo 2. For coalescing, it's checking if the > RHS is live at the "use" cycle. So it's checking VNI->def-1.But why is it looking at a use slot in this case, where the coalescer is trying to get the vaue number for the def of the RHS register so it can use that value number in the resulting merged live interval? The comment at the top of the loop is: 00695 // Loop over the value numbers of the LHS, seeing if any are defined from 00696 // the RHS. As I understyand it, it's looking for def-use chains from the RHS interval to the LHS interval. That says to me that it's looking for defs of the RHS value, not uses. Why should it expect that a value number defined in some live interval would also be used in that live interval at the use slot *before* the def? What am I missing? -Dave
On Tuesday 25 September 2007 13:28, David Greene wrote:> > So VNI->def is always modulo 2. For coalescing, it's checking if the > > RHS is live at the "use" cycle. So it's checking VNI->def-1. > > But why is it looking at a use slot in this case, where the coalescer is > trying to get the vaue number for the def of the RHS register so it can > use that value number in the resulting merged live interval? > > The comment at the top of the loop is: > > 00695 // Loop over the value numbers of the LHS, seeing if any are > defined from > 00696 // the RHS. > > As I understyand it, it's looking for def-use chains from the RHS interval > to the LHS interval.Ah, that's where I got it wrong. I think I get it now. We're looking at the copy "LHS = RHS" so it takes the def index from the LHS interval and "def-1" is the use index for "RHS" in the copy. It then tries to look up the live range for that use index. I believe I've discovered a problem with my new code so I'll go investigate that. -Dave