11 Commits

Author SHA1 Message Date
Nikita Popov
b7e51b4f13
[IPSCCP] Infer attributes on arguments (#107114)
During inter-procedural SCCP, also infer attributes on arguments, not
just return values. This allows other non-interprocedural passes to make
use of the information later.
2024-09-16 10:23:41 +02:00
Nikita Popov
04742f34b3 [SCCP] Add test for nonnull argument inference (NFC) 2024-09-09 10:28:49 +02:00
Nikita Popov
24fe1d4fd6
[SCCP] Infer return attributes in SCCP as well (#106732)
We can infer the range/nonnull attributes in non-interprocedural SCCP as
well. The results may be better after the function has been simplified.
2024-09-02 11:44:37 +02:00
Nikita Popov
d6ad551670
[IPSCCP] Infer nonnull return attribute (#106553)
Similarly to the existing range attribute inference, also infer the
nonnull attribute on function return values.

I think in practice FunctionAttrs will handle nearly all cases, the main
one I think it doesn't is cases involving branch conditions. But as we
already have the information here, we may as well materialize it.
2024-08-30 09:38:15 +02:00
Nikita Popov
ba52a09abe [IPSCCP] Add test for returning nonnull pointer (NFC) 2024-08-29 14:43:38 +02:00
Nikita Popov
7f59264d46
[IPSCCP] Intersect attribute info for interprocedural args (#106397)
IPSCCP can currently return worse results than SCCP for arguments that
are tracked interprocedurally, because information from attributes is
not used for them.

Fix this by intersecting in the attribute information when propagating
lattice values from calls.
2024-08-29 09:34:56 +02:00
Nikita Popov
b8c0e8ad10 [IPSCCP] Add extra tests for interprocedural arg attr handling (NFC) 2024-08-28 15:55:14 +02:00
Nikita Popov
657f26f038 [SCCP] Add more non-null roots
Also consider allocas non-null (subject to the usual caveats),
and consider nonnull/dereferenceable metadata on calls.
2024-08-27 15:53:22 +02:00
Nikita Popov
ed1c1da048 [SCCP] Add tests for more non-null roots (NFC) 2024-08-27 15:17:51 +02:00
Nikita Popov
1cea5c2138
[SCCP] Propagate non-null pointers (#106090)
Add NotConstant(Null) roots for nonnull arguments and then propagate
them through nuw/inbounds GEPs.

Having this functionality in SCCP is useful because it allows reliably
eliminating null comparisons, independently of how deeply nested they
are in selects/phis. This handles cases that would hit a cutoff in
ValueTracking otherwise.

The implementation is something of a MVP, there are a number of obvious
extensions (e.g. allocas are also non-null).
2024-08-27 09:13:41 +02:00
Nikita Popov
41f2f1f028 [SCCP] Add tests for non-null pointers (NFC) 2024-08-26 16:35:26 +02:00