[ArgPromotion] Make implementation offset based
authorNikita Popov <npopov@redhat.com>
Fri, 28 Jan 2022 16:22:58 +0000 (17:22 +0100)
committerNikita Popov <npopov@redhat.com>
Wed, 9 Feb 2022 08:35:01 +0000 (09:35 +0100)
commit68c1eeb4bad18753dbaa053a6c919c8f1a23fb9c
tree124db857c8c05284e9b262b6ad4d6f0e5426fd2b
parent47995a0ec92643f8b799c19103ed2c9222e63221
[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
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/test/Transforms/ArgumentPromotion/align.ll
llvm/test/Transforms/ArgumentPromotion/bitcasts.ll
llvm/test/Transforms/ArgumentPromotion/fp80.ll
llvm/test/Transforms/ArgumentPromotion/opaque-ptr.ll [new file with mode: 0644]