This is an archive of the discontinued LLVM Phabricator instance.

[MIRParser] Diagnose too large align values in MachineMemOperands
ClosedPublic

Authored by foad on Feb 23 2022, 3:46 AM.

Details

Summary

When parsing MachineMemOperands, MIRParser treated the "align" keyword
the same as "basealign". Really "basealign" should specify the
alignment of the MachinePointerInfo base value, and "align" should
specify the alignment of that base value plus the offset.

This worked OK when the specified alignment was no larger than the
alignment of the offset, but in cases like this it just caused
confusion:

STW killed %18, 4, %stack.1.ap2.i.i :: (store (s32) into %stack.1.ap2.i.i + 4, align 8)

MIRPrinter would never have printed this, with an offset of 4 but an
align of 8, so it must have been written by hand. MIRParser would
interpret "align 8" as "basealign 8", but I think it is better to give
an error and force the user to write "basealign 8" if that is what they
really meant.

Diff Detail

Event Timeline

foad created this revision.Feb 23 2022, 3:46 AM
foad requested review of this revision.Feb 23 2022, 3:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 23 2022, 3:46 AM

Needs parser test

rampitec added inline comments.Feb 23 2022, 8:53 AM
llvm/test/CodeGen/AMDGPU/merge-global-load-store.mir
413

Well, this is unlikely to happen in real life, but this was exactly my point writing this torture test: basealign is 4, and we have managed to know it is misaligned by 8, so ptr +4 has exactly align 8.

I believe MIR parser is correct, it just does what is written.

foad added inline comments.Feb 23 2022, 8:58 AM
llvm/test/CodeGen/AMDGPU/merge-global-load-store.mir
413

it just does what is written

No, it takes the "align" value as written and uses it to set the basealign field instead.

LGTM modulo test asked by Matt.

llvm/test/CodeGen/AMDGPU/merge-global-load-store.mir
413

Hm... Ok, given the MachineMemOperand::getAlign() implementation.

foad updated this revision to Diff 411070.Feb 24 2022, 4:11 AM

Add MIR tests.

arsenm accepted this revision.Feb 24 2022, 7:15 AM
This revision is now accepted and ready to land.Feb 24 2022, 7:15 AM
This revision was landed with ongoing or failed builds.Feb 24 2022, 7:37 AM
This revision was automatically updated to reflect the committed changes.