This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Add earlyclobber of destination register to atomic instructions
ClosedPublic

Authored by gonglingqin on Oct 10 2022, 8:37 PM.

Details

Summary

If the AM* atomic memory access instruction has the same register number as
rd and rj, the execution will trigger an Instruction Non-defined Exception.
If the AM* atomic memory access instruction has the same register number as
rd and rk, the execution result is uncertain.

Reference: https://github.com/loongson/LoongArch-Documentation

Diff Detail

Event Timeline

gonglingqin created this revision.Oct 10 2022, 8:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 10 2022, 8:37 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
gonglingqin requested review of this revision.Oct 10 2022, 8:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 10 2022, 8:37 PM
xry111 accepted this revision.Oct 10 2022, 8:58 PM

Why didn't we notice this before? :(

This revision is now accepted and ready to land.Oct 10 2022, 8:58 PM

Why didn't we notice this before? :(

It's really easy to ignore this problem until the executable starts running:)

xen0n accepted this revision.Oct 10 2022, 11:23 PM

Why didn't we notice this before? :(

Of course it's because RISCV AMO doesn't have this implementation feature/detail/quirk/wart (pick one suitable for you) ;-)

Why didn't we notice this before? :(

Of course it's because RISCV AMO doesn't have this implementation feature/detail/quirk/wart (pick one suitable for you) ;-)

I mean I had spent some time to find a way for describing our "feature" (or whatever) last year, and found "earlyclobber": https://github.com/xry111/llvm-project/blob/d4c6b92/llvm/lib/Target/LoongArch/LoongArchInstrInfoA.td#L42

So basically "why didn't I notice it before" :(.