This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Try to make the print of memory operand alignment a little more user friendly.
ClosedPublic

Authored by craig.topper on Jan 8 2021, 3:18 PM.

Details

Summary

Memory operands store a base alignment that does not factor in
the effect of the offset on the alignment.

Previously the printing code only printed the base alignment if
it was different than the size. If there is an offset, the reader
would need to figure out the effective alignment themselves. This
has confused me before and someone else was recently confused on
IRC.

This patch prints the possibly offset adjusted alignment if it is
different than the size. And prints the base alignment if it is
different than the alignment. The MIR parser has been updated to
read basealign in addition to align.

Diff Detail

Event Timeline

craig.topper created this revision.Jan 8 2021, 3:18 PM
craig.topper requested review of this revision.Jan 8 2021, 3:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 8 2021, 3:18 PM
Herald added a subscriber: wdng. · View Herald Transcript
arsenm added a comment.Jan 8 2021, 3:21 PM

Needs a dedicated parse/roundtrip test in test/CodeGen/MIR

jrtc27 added a comment.Jan 8 2021, 3:23 PM

🎉 (looks sensible to me but don't have a huge amount of experience with MIR)

Modify existing memory alignment test in memory_operands.mir to test more combinations of align/basealign presence.

arsenm accepted this revision.Jan 11 2021, 7:02 PM
This revision is now accepted and ready to land.Jan 11 2021, 7:02 PM
foad added a subscriber: foad.May 18 2021, 6:11 AM
foad added inline comments.
llvm/lib/CodeGen/MIRParser/MILexer.cpp
252

Shouldn't this be kw_basealign?