Page MenuHomePhabricator

[InlineSpiller] add assert about spills post terminators

Authored by nickdesaulniers on Apr 14 2020, 4:25 PM.



This invariant is being violated in the test case, related to the use of the relatively
new ability for callbr to have return values, and MachineBasicBlocks
with INLINEASM_BR terminators to emit live out register defs.

As noted in the comment, this triggers invariant violations in
MachineVerifier via llc -verify-machineinstrs or
llc -verify-regalloc, since only MachineInstrs that are terminators
are allowed to follow the first terminator. may rework this very assertion if we're
spilling via a (proposed) TCOPY MachineInstr.

Diff Detail

Event Timeline

I'm not particularly attached to this patch; just posting it for now. None of the current test cases in tree violate it, only the test case from does.

efriedma accepted this revision.Apr 14 2020, 5:29 PM

LGTM with a minor nit


Probably don't need the "This is commonly observed with" bit.

This revision is now accepted and ready to land.Apr 14 2020, 5:29 PM

Sure thing, I'll clean this up later today. And again, I'm not attached to this, so if we want to rip it out or change it for TCOPY, let's do it.

I want to first post my patch for an additional assert in branch folder. What I have I don't think will be controversial. One thing I noticed though is that MachineBasicBlock#terminators() is not tracking INLINEASM_BR's correctly, so I'll need to go fix that first, in order to post that assertion patch, to revisit this. Otherwise this assert will mask that assert.


Ah, it's because of MachineBasicBlock#getFirstTerminator() iterates backwards through the MachineBasicBlock's MachineInstrs to the first non-Terminal, then moves forward one and returns that.

The case in means MachineBasicBlock#getFirstTerminator() and thus MachineBasicBlock#terminators() are broken due to the unexpected spill location.

I can make by check more robust in my yet to be published patch by iterating each MachineInstr in a MachineBasicBlock, rather than just the termintors().

nickdesaulniers marked 2 inline comments as done.
  • drop comment about llc flags, as per @efriedma
nickdesaulniers marked an inline comment as done.Apr 15 2020, 12:57 PM
This revision was automatically updated to reflect the committed changes.