This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Add a basic MachineInstr unittest. NFC.
AcceptedPublic

Authored by ab on Feb 28 2017, 4:16 PM.

Details

Reviewers
MatzeB
Summary

David pointed out the lack of tests in r296007, which adds another mode to MI::print().

I'm not entirely convinced it's valuable, but I figured I'd give it a shot. I was wondering just how much effort it would take to write an MI test (turns out, a lot.)

So, this tests adds enough machinery to translate one MI from MIR (+IR), and uses that to test the 3 variants of print().

When (if) we merge MIR and MI dump, these tests should really just be replaced with our existing llc mir tests.

Diff Detail

Event Timeline

ab created this revision.Feb 28 2017, 4:16 PM
MatzeB accepted this revision.Feb 28 2017, 4:40 PM

So much boilerplate, but this is in line with the existing unittests/MI/LiveIntervalTest.cpp or unittests/Target/AArch64/InstSizes.cpp. LGTM.

BTW: I plan to present an alternative approach soon that introduces a special lcl testing pass that understands simple directive... But there is no reason to wait for that.

unittests/CodeGen/MachineInstrTest.cpp
35–36

I assume this selects LLVM_DEFAULT_TARGET_TRIPLE. Would this fail if that isn't defined? The test should at least exit gracefully and not segfault in that case...

This revision is now accepted and ready to land.Feb 28 2017, 4:40 PM