This is an archive of the discontinued LLVM Phabricator instance.

DAG: Don't pass 0 alignment value to allowsMisalignedMemoryAccesses
ClosedPublic

Authored by arsenm on Aug 12 2020, 5:16 PM.

Details

Summary

I think not unconditionally passing getDstAlign is broken, but leave
that for another change.

f85d3408e6e3e7710032abfaabdecd02ee0b5ced / D73964 started conditionally passing the alignment, which I don't understand. 0 is not a valid alignment value, so this should not use it.

Diff Detail

Event Timeline

arsenm created this revision.Aug 12 2020, 5:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2020, 5:16 PM
arsenm requested review of this revision.Aug 12 2020, 5:16 PM
rampitec accepted this revision.Aug 12 2020, 10:52 PM

LGTM, but probably allowsMisalignedMemoryAccesses() should just take Align argument instead.

This revision is now accepted and ready to land.Aug 12 2020, 10:52 PM
courbet added inline comments.Aug 17 2020, 11:58 PM
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
252

There's actually an overload that takes an Align. The old version is scheduled to go away. So please use the overload:

allowsMisalignedMemoryAccesses( VT, DstAS, Op.isFixedDstAlign() ? Op.getDstAlign() : Align(1))
253

Actually the overlapping load/store is not aligned as Op.getDstAlign() (consider the case of a 7-byte copy aligned to 4, then the overlapping 4 byte load-store would have align 1), so I think this should actually always be 1.

arsenm added inline comments.Aug 18 2020, 6:34 AM
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
252

There isn't actually. The LLT version uses Align, but the SelectionDAG version does not