LLVM/project db86f45llvm/include/llvm/Transforms/IPO Attributor.h, llvm/lib/Transforms/IPO AttributorAttributes.cpp Attributor.cpp

[Attributor] Introduce assumption accesses in AAPointerInfo

Assumptions can help us reason about memory content. This patch teaches
AAPointerInfo to reason about memory assumptions of the following form:

```
%x = load %ptr
... code not writing memory, may include branches ...
%c = %x == %val
... code not writing memory, may include branches ...
llvm.assume(%c)
```

Assumption accesses are recognized from the involved load (%x above).

Assumption accesses are treated special and neither as ordinary read or
write. We use read encoding with an extra flag. Reads are not impacting
other reads or writes. Writes could do that. We don't want assumptions
to impact other writes as they themselves only confirm a value, not

    [2 lines not shown]
DeltaFile
+211-99llvm/test/Transforms/Attributor/value-simplify-assume.ll
+84-3llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+14-1llvm/include/llvm/Transforms/IPO/Attributor.h
+1-1llvm/lib/Transforms/IPO/Attributor.cpp
+310-1044 files

LLVM/project cb8dae6llvm/include/llvm/IR IntrinsicsX86.td, llvm/test/MC/AArch64/SME2 mova.s

Merge branch 'main' into HEAD
DeltaFile
+6,177-0third-party/unittest/googletest/src/gtest.cc
+0-6,177llvm/utils/unittest/googletest/src/gtest.cc
+3,046-2,678llvm/include/llvm/IR/IntrinsicsX86.td
+17-5,689llvm/test/MC/AMDGPU/gfx11_asm_vop3.s
+5,521-0llvm/test/MC/AArch64/SME2/mova.s
+1-5,123llvm/test/MC/Disassembler/AMDGPU/gfx11_dasm_vop3.txt
+14,762-19,6674,315 files not shown
+198,948-112,0264,321 files

LLVM/project 304f1d5llvm/test/Transforms/Attributor nocapture-2.ll willreturn.ll

[IR] Switch everything to use memory attribute

This switches everything to use the memory attribute proposed in
https://discourse.llvm.org/t/rfc-unify-memory-effect-attributes/65579.
The old argmemonly, inaccessiblememonly and inaccessiblemem_or_argmemonly
attributes are dropped. The readnone, readonly and writeonly attributes
are restricted to parameters only.

The old attributes are auto-upgraded both in bitcode and IR.
The bitcode upgrade is a policy requirement that has to be retained
indefinitely. The IR upgrade is mainly there so it's not necessary
to update all tests using memory attributes in this patch, which
is already large enough. We could drop that part after migrating
tests, or retain it longer term, to make it easier to import IR
from older LLVM versions.

High-level Function/CallBase APIs like doesNotAccessMemory() or
setDoesNotAccessMemory() are mapped transparently to the memory
attribute. Code that directly manipulates attributes (e.g. via

    [4 lines not shown]
DeltaFile
+210-145llvm/test/Transforms/Attributor/nocapture-2.ll
+176-124llvm/test/Transforms/Attributor/willreturn.ll
+145-147llvm/test/Transforms/Attributor/range.ll
+111-113llvm/test/Transforms/Attributor/nocapture-1.ll
+109-110llvm/test/Transforms/Attributor/value-simplify.ll
+131-81llvm/test/Transforms/Attributor/dereferenceable-1.ll
+882-720250 files not shown
+3,685-3,500256 files

LLVM/project 846709bllvm/test/Transforms/Attributor value-simplify-pointer-info.ll liveness.ll

[Attribute] Clean up test prefixes (NFC)

Now that the legacy PM is no longer tested, the huge matrix of
test prefixes used by attributor tests is no longer needed and very
confusing for the casual reader. Reduce the prefixes down to just
CHECK, TUNIT and CGSCC.
DeltaFile
+1,632-1,632llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
+1,092-1,092llvm/test/Transforms/Attributor/liveness.ll
+948-948llvm/test/Transforms/Attributor/range.ll
+751-751llvm/test/Transforms/Attributor/value-simplify-assume.ll
+610-610llvm/test/Transforms/Attributor/nonnull.ll
+578-578llvm/test/Transforms/Attributor/value-simplify.ll
+5,611-5,611105 files not shown
+14,120-14,122111 files

LLVM/project 99c9b37llvm/test/Transforms/Attributor value-simplify-pointer-info.ll range.ll, llvm/test/Transforms/Attributor/ArgumentPromotion/X86 min-legal-vector-width.ll

[NFC][1/n] Remove -enable-new-pm=0 flags from lit tests

This is the first patch in a series intended for removing flag
-enable-new-pm=0 from lit tests. This is part of a bigger
effort of completely removing legacy code related to legacy
pass manager in favor of currently default new pass manager.

In this patch flag has been removed only from tests where no significant
change has been required because checks has been duplicated for
both PMs.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D134150
DeltaFile
+0-1,605llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
+0-1,217llvm/test/Transforms/OpenMP/parallel_region_merging.ll
+0-812llvm/test/Transforms/Attributor/range.ll
+0-480llvm/test/Transforms/Attributor/willreturn.ll
+0-399llvm/test/Transforms/Attributor/value-simplify.ll
+0-292llvm/test/Transforms/Attributor/ArgumentPromotion/X86/min-legal-vector-width.ll
+0-4,805145 files not shown
+0-7,484151 files

LLVM/project 09c8983libcxx/test/std/language.support/support.limits/support.limits.general version.version.pass.cpp version.version.compile.pass.cpp, libcxx/test/std/utilities/format/format.functions locale-specific_form.pass.cpp

Merge branch 'main' into irbuilder-extract-refactor
DeltaFile
+4,801-4,803llvm/lib/Target/AArch64/AArch64PerfectShuffle.h
+0-5,015libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
+4,996-0libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
+2,023-2,020llvm/docs/AMDGPU/AMDGPUAsmGFX10.rst
+1,653-1,649libcxx/test/std/utilities/format/format.functions/locale-specific_form.pass.cpp
+2,963-0llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
+16,436-13,4877,445 files not shown
+205,894-116,0887,451 files

LLVM/project e87f10allvm/test/Transforms/Attributor range.ll value-simplify-pointer-info.ll

[Attributor] CGSCC pass should not recompute results outside the SCC (reapply)

When we run the CGSCC pass we should only invest time on the SCC. We can
initialize AAs with information from the module slice but we should not
update those AAs. We make an exception for are call site of the SCC as
they are helpful providing information for the SCC.

Minor modifications to pointer privatization allow us to perform it even
in the CGSCC pass, similar to ArgumentPromotion.
DeltaFile
+1,104-438llvm/test/Transforms/Attributor/range.ll
+953-517llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
+767-365llvm/test/Transforms/Attributor/value-simplify-assume.ll
+479-467llvm/test/Transforms/Attributor/align.ll
+596-239llvm/test/Transforms/Attributor/value-simplify.ll
+460-238llvm/test/Transforms/Attributor/returned.ll
+4,359-2,26473 files not shown
+8,757-4,61579 files

LLVM/project 39a68ccllvm/test/Transforms/Attributor range.ll value-simplify-pointer-info.ll

Revert "[Attributor] CGSCC pass should not recompute results outside the SCC"

This reverts commit 0d7f81e31315f8cda56ce6fde5ff5145e0325c51, it caused
the AMDGPU tests that use the Attributor to fail.
DeltaFile
+438-1,104llvm/test/Transforms/Attributor/range.ll
+521-949llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
+365-767llvm/test/Transforms/Attributor/value-simplify-assume.ll
+472-484llvm/test/Transforms/Attributor/align.ll
+246-606llvm/test/Transforms/Attributor/value-simplify.ll
+238-460llvm/test/Transforms/Attributor/returned.ll
+2,280-4,37076 files not shown
+5,069-9,00382 files

LLVM/project 0d7f81ellvm/test/Transforms/Attributor range.ll value-simplify-pointer-info.ll

[Attributor] CGSCC pass should not recompute results outside the SCC

When we run the CGSCC pass we should only invest time on the SCC. We can
initialize AAs with information from the module slice but we should not
update those AAs.
DeltaFile
+1,104-438llvm/test/Transforms/Attributor/range.ll
+949-521llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
+767-365llvm/test/Transforms/Attributor/value-simplify-assume.ll
+484-472llvm/test/Transforms/Attributor/align.ll
+606-246llvm/test/Transforms/Attributor/value-simplify.ll
+460-238llvm/test/Transforms/Attributor/returned.ll
+4,370-2,28076 files not shown
+9,003-5,06982 files

LLVM/project 573017fllvm/lib/IR Verifier.cpp, llvm/lib/Target/AArch64 AArch64PerfectShuffle.h

Merge branch 'main' into irbuilder-extract-refactor
DeltaFile
+6,563-6,564llvm/lib/Target/AArch64/AArch64PerfectShuffle.h
+7,027-0llvm/test/CodeGen/CSKY/atomic-rmw.ll
+3,824-0llvm/test/CodeGen/RISCV/rvv/setcc-int-vp.ll
+1,912-1,839llvm/lib/IR/Verifier.cpp
+3,241-0llvm/test/CodeGen/RISCV/rvv/setcc-integer.ll
+0-3,106llvm/test/CodeGen/RISCV/rvv/setcc-integer-rv32.ll
+22,567-11,5092,661 files not shown
+103,374-47,9852,667 files

LLVM/project af30de7llvm/include/llvm/Transforms/IPO Attributor.h, llvm/lib/Transforms/IPO AttributorAttributes.cpp Attributor.cpp

[Attributor] Introduce AAInstanceInfo

The Attributor, as many other parts in LLVM, uses pointer equivalence
for `llvm::Value`s. This only works as long as `llvm::Value`s are
dynamically unique, or, to be exact, we will never end up with the same
`llvm::Value` representing two dynamic instances. We already provided a
helper to check the former, namely `AA::isDynamicallyUnique`, however we
could not check the latter. In this patch we move the logic into a
separate AA which helps with the growing complexity and use cases. We
also extend the interface to answer the second question rather than the
first. So we do not determine dynamically uniqueness but if we might end
up with the `llvm::Value` describing a different dynamic instance. Note
that the latter is very much tied to the Attributor capabilities to look
through memory, recursion, etc. so we need to update the logic as we go.
DeltaFile
+160-116llvm/test/Transforms/OpenMP/parallel_region_merging.ll
+173-6llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+44-1llvm/include/llvm/Transforms/IPO/Attributor.h
+16-8llvm/test/Transforms/Attributor/ArgumentPromotion/alloca-as.ll
+6-16llvm/lib/Transforms/IPO/Attributor.cpp
+8-8llvm/test/Transforms/Attributor/callbacks.ll
+407-1555 files not shown
+415-17211 files

LLVM/project c42aa1bllvm/include/llvm/Transforms/IPO Attributor.h, llvm/lib/Transforms/IPO Attributor.cpp AttributorAttributes.cpp

[Attributor] Keep loads feeding in `llvm.assume` if stores stays

If a load is only used by an `llvm.assume` and the stores feeding into
the load are not removable, keep the load.
DeltaFile
+62-94llvm/test/Transforms/Attributor/value-simplify-assume.ll
+58-12llvm/lib/Transforms/IPO/Attributor.cpp
+42-6llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+22-7llvm/include/llvm/Transforms/IPO/Attributor.h
+2-2llvm/test/Transforms/Attributor/align.ll
+186-1215 files

LLVM/project 3e8c436llvm/include/llvm/Transforms/IPO Attributor.h, llvm/lib/Transforms/IPO AttributorAttributes.cpp Attributor.cpp

[Attributor] Visit droppable uses in AAIsDead

If we ignore droppable users everything only used in llvm.assume (among
other things) is going to be deleted as dead. This is not helpful.
Instead we want to only delete things we actually don't need anymore. A
follow up will deal with loads in a smarter way.
DeltaFile
+44-16llvm/test/Transforms/Attributor/value-simplify-assume.ll
+4-2llvm/test/Transforms/Attributor/nonnull.ll
+3-2llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+2-1llvm/lib/Transforms/IPO/Attributor.cpp
+1-0llvm/include/llvm/Transforms/IPO/Attributor.h
+54-215 files

LLVM/project dd92b29llvm/test/Transforms/Attributor value-simplify-assume.ll

[Attributor][NFC] Pre-commit new test case
DeltaFile
+989-0llvm/test/Transforms/Attributor/value-simplify-assume.ll
+989-01 files