Page MenuHomePhabricator

[LoongArch] Add codegen support for atomic fence, atomic load and atomic store
ClosedPublic

Authored by gonglingqin on Jun 30 2022, 2:58 AM.

Diff Detail

Unit TestsFailed

TimeTest
60,090 msx64 debian > AddressSanitizer-x86_64-linux-dynamic.TestCases::scariness_score_test.cpp
Script: -- : 'RUN: at line 4'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 -shared-libasan -O0 /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/asan/TestCases/scariness_score_test.cpp -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Output/scariness_score_test.cpp.tmp
60,110 msx64 debian > AddressSanitizer-x86_64-linux.TestCases::scariness_score_test.cpp
Script: -- : 'RUN: at line 4'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 -O0 /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/asan/TestCases/scariness_score_test.cpp -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/scariness_score_test.cpp.tmp
60,110 msx64 debian > Clang.Driver::emit-reproducer.c
Script: -- : 'RUN: at line 1'; rm -rf /var/lib/buildkite-agent/builds/llvm-project/build/tools/clang/test/Driver/Output/emit-reproducer.c.tmp && mkdir /var/lib/buildkite-agent/builds/llvm-project/build/tools/clang/test/Driver/Output/emit-reproducer.c.tmp

Event Timeline

gonglingqin created this revision.Jun 30 2022, 2:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 30 2022, 2:58 AM
gonglingqin requested review of this revision.Jun 30 2022, 2:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 30 2022, 2:58 AM
xry111 added inline comments.Jul 2 2022, 4:28 AM
llvm/test/CodeGen/LoongArch/ir-instruction/load-store-atomic.ll
140

GCC uses one instruction for this: amswap_db.d $zero, $a1, $a0, and to me it's correct. Can we also use it?

Likewise for i32 store release operation.

lkail added a subscriber: lkail.Jul 2 2022, 4:35 AM
lkail added inline comments.
llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp
116

You may need to add tests in lvm/test/Transforms/AtomicExpand/LoongArch.

gonglingqin added inline comments.Jul 3 2022, 8:35 PM
llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp
116

Thanks for reminding me.I will add tests.

llvm/test/CodeGen/LoongArch/ir-instruction/load-store-atomic.ll
140

Thank you for your reminder. This may be possible. Further, we can generate different instructions according to constraints (such as instructions without fences when unordered). I'm not sure whether this optimization should be implemented in this patch or another patch. Do you have any suggestions?

Address @lkail's comments.

SixWeining added inline comments.Jul 4 2022, 12:21 AM
llvm/test/Transforms/AtomicExpand/LoongArch/load-store-atomic.ll
3

It should be --.

3

ditto

xry111 added inline comments.Jul 4 2022, 12:29 AM
llvm/test/CodeGen/LoongArch/ir-instruction/load-store-atomic.ll
140

Maybe in another patch, as these two instructions are not explicitly emitted by the target code, but by some "internal LLVM magic".

gonglingqin added inline comments.Jul 4 2022, 1:10 AM
llvm/test/CodeGen/LoongArch/ir-instruction/load-store-atomic.ll
140

Thanks for the suggestion, I will handle it in another patch.

llvm/test/Transforms/AtomicExpand/LoongArch/load-store-atomic.ll
3

Thanks. I will change that.

3

Thanks. I will change that.

Address @SixWeining's comments.

xen0n accepted this revision.Jul 11 2022, 12:00 AM

I agree with @xry111 that the optimization to use amswap_db.d $zero, x, y for atomic stores can be done in a later patch. For now this LGTM but I'd like someone else to take a look too.

This revision is now accepted and ready to land.Jul 11 2022, 12:00 AM
SixWeining accepted this revision.Jul 13 2022, 12:05 AM
This revision was landed with ongoing or failed builds.Jul 13 2022, 12:27 AM
This revision was automatically updated to reflect the committed changes.