Page MenuHomePhabricator

[GlobalISel][AArch64][NFC] Use getDefIgnoringCopies from Utils where we can
ClosedPublic

Authored by paquette on Jul 10 2019, 10:10 AM.

Details

Summary

There are a few places where we walk over copies throughout AArch64InstructionSelector.cpp. In Utils, there's a function that does exactly this which we can use instead.

Note that the utility function works with the case where we run into a COPY from a physical register. We've run into bugs with this a couple times, so using it should defend us from similar future bugs.

Diff Detail

Repository
rL LLVM

Event Timeline

paquette created this revision.Jul 10 2019, 10:10 AM
arsenm added a subscriber: arsenm.Jul 10 2019, 10:20 AM
arsenm added inline comments.
llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
3239–3240 ↗(On Diff #209003)

I'm not sure getDefIgnoringCopies handles physical registers correctly, does that have a test somewhere?

paquette marked an inline comment as done.Jul 10 2019, 10:31 AM
paquette added inline comments.
llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
3239–3240 ↗(On Diff #209003)

It should. It gets the source type using MRI.getType, which should return LLT {} when you give it a physical register. This should make the source type invalid, which ends the search.

I'll add a test anyway though, since I'm not sure if one exists.

paquette updated this revision to Diff 209018.Jul 10 2019, 10:46 AM

Add a testcase showing that we won't crash if we encounter a copy from a physical register.

This revision is now accepted and ready to land.Jul 10 2019, 11:27 AM
This revision was automatically updated to reflect the committed changes.