This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Improve codegen for atomic ops
AbandonedPublic

Authored by SixWeining on Aug 31 2023, 4:59 AM.

Details

Summary

This PR improves memory barriers generated by atomic operations.

Memory barrier semantics of LL/SC:
LL: <memory-barrier> + <load-exclusive>
SC: <store-conditional> + <memory-barrier>

Changes:

  1. Remove unnecessary memory barriers before LL and between LL/SC.
  2. Fix acquire semantics. (If the SC instruction is not executed, then acquire semantics cannot be guaranteed. So, acquire barrier need to be generated when memory ordering has acquire.)

Diff Detail

Event Timeline

hev created this revision.Aug 31 2023, 4:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2023, 4:59 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
hev requested review of this revision.Aug 31 2023, 4:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2023, 4:59 AM
hev added inline comments.Aug 31 2023, 5:01 AM
llvm/lib/Target/LoongArch/LoongArchExpandAtomicPseudoInsts.cpp
583

Request to update in D151655

xry111 added a subscriber: xry111.

I'll see if a similar change is desired for GCC too.

SixWeining commandeered this revision.Oct 12 2023, 12:45 AM
SixWeining abandoned this revision.
SixWeining edited reviewers, added: hev; removed: SixWeining.