[AArch64] Add Defs=[NZCV] to MTE loop pseudos.
authorSimon Tatham <simon.tatham@arm.com>
Mon, 21 Aug 2023 07:43:21 +0000 (08:43 +0100)
committerTobias Hieta <tobias@hieta.se>
Thu, 31 Aug 2023 07:00:36 +0000 (09:00 +0200)
commit844f1e5a026c43ffc556679dcec767ece704a40d
tree90008d31af9507e055162b226048a3d7653aa3ca
parent078e20cade5518d7df48c75ac25c3179f825f70a
[AArch64] Add Defs=[NZCV] to MTE loop pseudos.

The `STGloop` family of pseudo-instructions all expand to a loop which
iterates over a region of memory setting all its MTE tags to a given
value. The loop writes to the flags in order to check termination. But
the unexpanded pseudo-instructions were not marked as modifying the
flags. Therefore it was possible for one to end up in a location where
the flags were live, and then the loop would corrupt them.

We spotted the effect of this in a libc++ test involving a lot of
complicated inlining, and haven't been able to construct a smaller
test case that demonstrates actual incorrect output code. So my test
here is just checking that `implicit-def $nzcv` shows up on the
pseudo-instructions as they're output from isel.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D158262

(cherry picked from commit b09c575975b691e988a0f2e31d632c5f1038ab1d)
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/test/CodeGen/AArch64/memtag-loop-nzcv.ll [new file with mode: 0644]