llvm-project/llvm/lib/Transforms
Patrick Walton 01859da84b [AliasAnalysis] Introduce getModRefInfoMask() as a generalization of pointsToConstantMemory().
The pointsToConstantMemory() method returns true only if the memory pointed to
by the memory location is globally invariant. However, the LLVM memory model
also has the semantic notion of *locally-invariant*: memory that is known to be
invariant for the life of the SSA value representing that pointer. The most
common example of this is a pointer argument that is marked readonly noalias,
which the Rust compiler frequently emits.

It'd be desirable for LLVM to treat locally-invariant memory the same way as
globally-invariant memory when it's safe to do so. This patch implements that,
by introducing the concept of a *ModRefInfo mask*. A ModRefInfo mask is a bound
on the Mod/Ref behavior of an instruction that writes to a memory location,
based on the knowledge that the memory is globally-constant memory (in which
case the mask is NoModRef) or locally-constant memory (in which case the mask
is Ref). ModRefInfo values for an instruction can be combined with the
ModRefInfo mask by simply using the & operator. Where appropriate, this patch
has modified uses of pointsToConstantMemory() to instead examine the mask.

The most notable optimization change I noticed with this patch is that now
redundant loads from readonly noalias pointers can be eliminated across calls,
even when the pointer is captured. Internally, before this patch,
AliasAnalysis was assigning Ref to reads from constant memory; now AA can
assign NoModRef, which is a tighter bound.

Differential Revision: https://reviews.llvm.org/D136659
2022-10-31 13:03:41 -07:00
..
AggressiveInstCombine [AggressiveInstCombine] Load merge the reverse load pattern of consecutive loads. 2022-10-19 11:22:58 +01:00
CFGuard [NFC] Fix warning 2022-08-23 20:50:37 -05:00
Coroutines [PrintPipeline] Handle CoroConditionalWrapper and add more verification 2022-10-12 09:36:45 -07:00
Hello
IPO [AliasAnalysis] Introduce getModRefInfoMask() as a generalization of pointsToConstantMemory(). 2022-10-31 13:03:41 -07:00
InstCombine [AliasAnalysis] Introduce getModRefInfoMask() as a generalization of pointsToConstantMemory(). 2022-10-31 13:03:41 -07:00
Instrumentation Reland "[PGO] Make emitted symbols hidden" 2022-10-26 17:13:05 +00:00
ObjCARC [ObjCARC][NFC] Fix defined but not used warning from D135041 2022-10-25 15:16:42 +08:00
Scalar [AliasAnalysis] Introduce getModRefInfoMask() as a generalization of pointsToConstantMemory(). 2022-10-31 13:03:41 -07:00
Utils [BasicBlockUtils] Add a new way for CreateControlFlowHub() 2022-10-31 08:58:54 -05:00
Vectorize [SLP]Fix a crash in the analysis of the compatible cmp operands. 2022-10-31 09:47:25 -07:00
CMakeLists.txt