[LLVMdev] Isel DAG documentation?

David Given dg at cowlark.com
Sat Mar 8 15:28:44 PST 2014


On 3/8/14, 7:18 AM, Tim Northover wrote:
[...]
> And TargetOpcodes.h for a few of the post-ISel ones (mostly they're in
> MachineInstr form, but you'll see them with -view-sched-dags, and
> occasionally before).

Thanks very much; but I'm afraid it's not helping much... if only I
could find some loose ends to unravel, I'm sure I can make this work (I
have compiler experience elsewhere, just not with LLVM), but no matter
how much I pick I can't make anything come loose!

Some specific questions:

(1) Given the DAG: i32 = GlobalAddress<i32* @i>

...I would expect to be able to select for it with an instruction
pattern of this form:

def MOVar : S32<
  (outs GR32:$rD), (ins i32imm:$addr),
  "mov $rD, $addr",
  [(set GR32:$rD, globaladdr:$addr)]
>;

(I'm aware the i32imm in the ins field is wrong, but I don't think I've
got far enough for that to be a problem yet.) What actually happens when
I try it is the compiler stack dumps, producing debug tracing that looks
like this:

x7f914882e210: i32 = <<Unknown Machine Node #65509>> 0x7f914882e210
[ORD=2] [ID=1]
  0x7f914882e210: i32 = <<Unknown Machine Node #65509>> 0x7f914882e210
[ORD=2] [ID=1]
    0x7f914882e210: i32 = <<Unknown Machine Node #65509>> 0x7f914882e210
[ORD=2] [ID=1]
    ...etc...

It seems to have somehow managed to create a cycle in the DAG, which is
of course wrong. But how? Has it replaced the GlobalAddress node with
the MOVar node and then updated $addr to refer to the MOVar node? I'm
not sure what I should be doing here --- I can't select for the
enclosing CopyToReg node, and GlobalAddress is a leaf...

(2) Even when I do manage to generate machine instructions, they're all
discarded because they're dead. This is leading to very fast but
slightly flawed code (all I get is a return instruction).

My best guess is that this is because I'm incorrectly wiring up the
function outputs, resulting in the compiler discarding the instructions
because the result isn't used. Except I'm using precisely the same
function lowering as one of the other targets. How do I find out what's
happening here?

-- 
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│
│ "You cannot truly appreciate _Atlas Shrugged_ until you have read it
│ in the original Klingon." --- Sea Wasp on r.a.sf.w

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 876 bytes
Desc: OpenPGP digital signature
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140308/61a6c3a4/attachment.sig>


More information about the llvm-dev mailing list