This is an archive of the discontinued LLVM Phabricator instance.

GlobalISel: Handle llvm.localescape
ClosedPublic

Authored by arsenm on Jul 29 2020, 7:55 AM.

Details

Summary

This one is pretty easy and shrinks the list of unhandled
intrinsics. I'm not sure how relevant the insert point is. Using the
insert position of EntryBuilder will place this after
constants. SelectionDAG seems to end up emitting these after argument
copies and before anything else, but I don't think it really
matters. This also ends up emitting these in the opposite order from
SelectionDAG, but I don't think that matters either.

This also needs a fix to stop the later passes dropping this as a dead
instruction. DeadMachineInstructionElim's version of isDead special
cases LOCAL_ESCAPE for some reason, and I'm not sure why it's excluded
from MachineInstr::isLabel (or why isDead doesn't check it).

I also noticed DeadMachineInstructionElim never considers inline asm
as dead, but GlobalISel will drop asm with no constraints.

Diff Detail

Event Timeline

arsenm created this revision.Jul 29 2020, 7:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2020, 7:55 AM
arsenm requested review of this revision.Jul 29 2020, 7:55 AM
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
1687

Maybe pull the GlobalValue::dropLLVMManglingEscape(MF->getName()) out of the loop?

1695

Move this out of the loop?

1696

Apparently MachineBasicBlock lets you insert ranges of instructions at once:

/// Insert a range of instructions into the instruction list before I.
template<typename IT>
void insert(iterator I, IT S, IT E) {
  assert((I == end() || I->getParent() == this) &&
         "iterator points outside of basic block");
  Insts.insert(I.getInstrIterator(), S, E);
}

If this accepts a vector, then you could probably use it to reproduce SDAG's ordering.

(Or I guess you could iterate over the arguments starting at CI.getNumArgOperands() instead of 0)

arsenm updated this revision to Diff 281652.Jul 29 2020, 10:17 AM

Hoist out of loop.

I tried reversing the loop, but it makes things more difficult to follow. Apparently reverse(enumerate()) doesn't work, I'm not sure it's worth doing something less than obvious to produce the less intuitive order the DAG produces

paquette accepted this revision.Aug 3 2020, 9:18 AM

LGTM

This revision is now accepted and ready to land.Aug 3 2020, 9:18 AM