Mark gc.relocate and gc.result as readnone
authorPhilip Reames <listmail@philipreames.com>
Fri, 5 Mar 2021 18:07:17 +0000 (10:07 -0800)
committerPhilip Reames <listmail@philipreames.com>
Fri, 5 Mar 2021 18:07:17 +0000 (10:07 -0800)
commitf352463ade6e49c3b0275f296d9190d828b7630b
treefdee86a299ccf90f4d56117d8580a2c87ef943f1
parent9fe46d6487b20b7356bdef93ff195fdd6010ad3d
Mark gc.relocate and gc.result as readnone

For some reason, we had been marking gc.relocates as reading memory. There's no known reason for this, and I suspect it to be a legacy of very early implementation conservatism.  gc.relocate and gc.result are simply projections of the return values from the associated statepoint.  Note that the LangRef has always declared them readnone.

The EarlyCSE change is simply moving the special casing from readonly to readnone handling.

As noted by the test diffs, this does allow some additional CSE when relocates are separated by stores, but since we generate gc.relocates in batches, this is unlikely to help anything in practice.

This was reviewed as part of https://reviews.llvm.org/D97974, but split at reviewer request before landing.  The motivation is to enable the GVN changes in that patch.
llvm/include/llvm/IR/Intrinsics.td
llvm/lib/Transforms/Scalar/EarlyCSE.cpp
llvm/test/Transforms/EarlyCSE/gc_relocate.ll
llvm/test/Transforms/GVN/gc_relocate.ll