I'm forwarding this to llvmdev so it doesn't get lost in the sea of commits... -Dave ---------- Forwarded Message ---------- Subject: Re: [llvm-commits] [llvm] r48521 - in /llvm/trunk: include/llvm/CodeGen/LiveVariables.h lib/CodeGen/LiveVariables.cpp test/CodeGen/PowerPC/2008-03-18-RegScavengerAssert.ll test/CodeGen/X86/x86-64-ret0.ll Date: Friday 28 March 2008 16:34 From: David Greene <dag at cray.com> To: llvm-commits at cs.uiuc.edu Cc: Chris Lattner <clattner at apple.com> On Tuesday 18 March 2008 23:59, Chris Lattner wrote:> How about using reg_iterators to do this? I assume this only applies > to vregs. If you walk the use_iterator list for the register, you can > very efficiently discard uses in other blocks (check User->getparent() > == MBB). Any uses within the same block are either a) in phi nodes, > in which case they are above the instruction or b) users later in the > block. > > If the representation is not in SSA form, you have to do some more > checks, but this should be a lot faster than scanning the whole > machine block. MBB's can be very large after all :)Ack. I just started looking at using reg_iterators elsewhere but wasn't aware of this non-SSA caveat. Can you elaborate? -Dave -------------------------------------------------------
On Mar 30, 2008, at 11:17 AM, David Greene wrote:> I'm forwarding this to llvmdev so it doesn't get lost in the sea of > commits...reg_iterators are independent of SSA or not. The basic issue is that if you loop over uses or defs of a register, it will return *all* the uses/defs of that register in the current function. If the value is SSA form, it is reasonable to say "give me the first def" and expect it to be the only def. For multiply defined values like physregs, this is not true, because the reg can have multiple defs. That said, ref_iterator and variants will always do what they are documented to, they just don't magically provide ssa-like properties for physregs. -Chris
On Sunday 30 March 2008 01:30:40 pm Chris Lattner wrote:> On Mar 30, 2008, at 11:17 AM, David Greene wrote: > > I'm forwarding this to llvmdev so it doesn't get lost in the sea of > > commits... > > reg_iterators are independent of SSA or not. The basic issue is that > if you loop over uses or defs of a register, it will return *all* the > uses/defs of that register in the current function. If the value is > SSA form, it is reasonable to say "give me the first def" and expect > it to be the only def. For multiply defined values like physregs, > this is not true, because the reg can have multiple defs.Gotcha. This is exactly what I want. Thanks for the explanation. For non-SSA values, is there some indication of which defs reach which uses? I don't need this right now but I can imagine using it in the future. -Dave