This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Check opcode before trying to extract register from operand
ClosedPublic

Authored by tellenbach on Aug 21 2023, 6:03 PM.

Details

Summary

When matching FNEG patterns for the MachineCombiner we need to check for
opcodes first, before trying to extract a register from an operand.
Otherwise handling of instructions with non-register operands causes the
compiler to crash.

Diff Detail

Event Timeline

tellenbach created this revision.Aug 21 2023, 6:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 21 2023, 6:03 PM
tellenbach requested review of this revision.Aug 21 2023, 6:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 21 2023, 6:03 PM
jroelofs accepted this revision.Aug 21 2023, 9:47 PM

Suggest using llvm/utils/update_llc_test_checks.py to write the CHECKs, so they're easier to update later.

Otherwise LGTM.

This revision is now accepted and ready to land.Aug 21 2023, 9:47 PM
MattDevereau requested changes to this revision.Aug 22 2023, 3:19 AM

The change looks good to me but the test needs tightening up.

inline-asm-empty-template.ll Is too generic of a file name, and it's not actually a template. This should be specifically referencing fneg.

llvm/test/CodeGen/AArch64/inline-asm-empty-template.ll
6 ↗(On Diff #552180)

This test should be renamed to something that reflects what this is actually testing instead of just @a. @emit_fneg_with_non_register_operand or something along those lines. At a glance you can't really tell why this test exists out of context with the changes.

17 ↗(On Diff #552180)

This line should be explicitly checked, or else the test is too flimsy. I can replace this line with %fneg = fadd double %1, %1 which doesn't test your change at all and this test still passes.

; CHECK: fneg d1, d0

This revision now requires changes to proceed.Aug 22 2023, 3:19 AM

It may be simpler for the test to be an mir test if it testing the MachineCombiner. It should be less susceptible to bitrot if any of the proceeding optimizations before it change.

Thanks, I've added a mir test that checks for fneg and gave it the name Matt suggested.

MattDevereau accepted this revision.Aug 23 2023, 6:45 AM
This revision is now accepted and ready to land.Aug 23 2023, 6:45 AM