This is an archive of the discontinued LLVM Phabricator instance.

Add support for atomic memory copy lowering
ClosedPublic

Authored by ebrevnov on Jan 28 2022, 1:40 AM.

Details

Summary

Currently, the utility supports lowering of non atomic memory transfer routines only. This patch adds support for atomic version of memcopy. This may be useful for targets not supporting atomic memcopy.

Diff Detail

Event Timeline

ebrevnov created this revision.Jan 28 2022, 1:40 AM
ebrevnov requested review of this revision.Jan 28 2022, 1:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 28 2022, 1:40 AM
ebrevnov updated this revision to Diff 403931.Jan 28 2022, 2:00 AM

Source and destionation of atomic memcopy may not overlap by sepcification

ebrevnov edited the summary of this revision. (Show Details)Jan 28 2022, 2:05 AM
ebrevnov added reviewers: sfertile, arsenm.
yurai007 added inline comments.
llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp
517

nit: is there any reason for templating first parameter? For now we only pass concrete MemCpyInst as argument.

ebrevnov added inline comments.Jan 31 2022, 5:03 AM
llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp
517

Oh, you are right... Originally, there was call to canOverlap from expandAtomicMemCpyAsLoop passing AtomicMemCpyInst. Later I realized that this call is not required.

arsenm added a comment.Feb 9 2022, 9:07 AM

A lit test using -amdgpu-lower-mem-intrinsics would be more maintainable

Herald added a project: Restricted Project. · View Herald TranscriptMar 29 2022, 1:09 AM
Herald added a subscriber: hsmhsm. · View Herald Transcript
arsenm added inline comments.Mar 30 2022, 6:32 AM
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
719

Bot is right, missing space before +=

llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h
138–145

We should probably move these to use Align (separate patch)

llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp
261–273

Typo s/Residal/Residual

309

Might as well make this opaque pointer friendly with getWithSamePointeeType

ebrevnov updated this revision to Diff 420385.Apr 4 2022, 11:17 PM
ebrevnov marked an inline comment as done.

Rebase + formatting

llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h
138–145

yep.

llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp
309

Generated bitcast changes pointee type... getWithSamePointeeType is not applicable here...

ebrevnov updated this revision to Diff 420386.Apr 4 2022, 11:20 PM
ebrevnov marked an inline comment as done.

Typo fixed Residal->Residual

arsenm accepted this revision.Apr 5 2022, 6:04 PM
arsenm added inline comments.
llvm/unittests/Transforms/Utils/MemTransferLowering.cpp
211

Swap these for correct expected/actual message

215

Ditto

This revision is now accepted and ready to land.Apr 5 2022, 6:04 PM
This revision was landed with ongoing or failed builds.Apr 7 2022, 8:41 PM
This revision was automatically updated to reflect the committed changes.