Commit Graph

6 Commits

Author SHA1 Message Date
Nikita Popov 217e85761c [ArgPromotion] Remove legacy PM support
Support for the legacy pass manager in ArgPromotion causes
complications in D125485. As the legacy pass manager for middle-end
optimizations is unsupported, drop ArgPromotion from the legacy
pipeline, rather than introducing additional complexity to deal
with it.

Differential Revision: https://reviews.llvm.org/D128536
2022-06-27 09:42:17 +02:00
Pavel Samolysov d6852155b9 [ArgPromotion] Add tests for already seen offsets (NFC)
If a load with the same offset has already been seen but the load had
a lower alignment, the pass has to check whether the pointer is
dereferenceable and is sufficiently aligned (so, the new alignment must
be taken into account).
2022-05-13 13:29:38 +03:00
Nikita Popov 68c1eeb4ba [ArgPromotion] Make implementation offset based
This rewrites ArgPromotion to be based on offsets rather than GEP
structure. We inspect all loads at constant offsets and remember
which types are loaded at which offsets. Then we promote based on
those types.

This generalizes ArgPromotion to work with bitcasted loads, and
is compatible with opaque pointers.

This patch also fixes incorrect handling of alignment during
argument promotion. Previously, the implementation only checked
that the pointer is dereferenceable, but was happy to speculate
overaligned loads. (I would have fixed this separately in advance,
but I found this hard to do with the previous implementation
approach).

Differential Revision: https://reviews.llvm.org/D118685
2022-02-09 09:35:01 +01:00
Nikita Popov b896334834 [ArgPromotion] Check dereferenceability on argument as well
Before walking all the callers, check whether we have a
dereferenceable attribute directly on the argument.

Also make it clearer that the code currently does not treat
alignment correctly.
2022-02-08 10:29:51 +01:00
Nikita Popov c2b476767e [ArgPromotion] Test dereferenceable annotation on callee (NFC)
While we check dereferenceability of all callers, we don't check
dereferenceability annotations on the callee.
2022-02-08 10:27:17 +01:00
Nikita Popov a24cc48bc6 [ArgPromotion] Add alignment test (NFC)
This shows a miscompile in the current argpromotion implementation:
We may speculatively execute overaligned loads.
2022-02-01 10:45:14 +01:00