Teach SROA to cope with wrapper aggregates. These show up a lot in ABI
authorChandler Carruth <chandlerc@gmail.com>
Sat, 13 Oct 2012 10:49:33 +0000 (10:49 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sat, 13 Oct 2012 10:49:33 +0000 (10:49 +0000)
commit07525a6be6bce604f3b528c91973ac4e66742266
tree96d66d8fdab7bb502cd9042ed36a58796b180e45
parentac104272d9fc42af8dc6853853b96d489685e5a7
Teach SROA to cope with wrapper aggregates. These show up a lot in ABI
type coercion code, especially when targetting ARM. Things like [1
x i32] instead of i32 are very common there.

The goal of this logic is to ensure that when we are picking an alloca
type, we look through such wrapper aggregates and across any zero-length
aggregate elements to find the simplest type possible to form a type
partition.

This logic should (generally speaking) rarely fire. It only ends up
kicking in when an alloca is accessed using two different types (for
instance, i32 and float), and the underlying alloca type has wrapper
aggregates around it. I noticed a significant amount of this occurring
looking at stepanov_abstraction generated code for arm, and suspect it
happens elsewhere as well.

Note that this doesn't yet address truly heinous IR productions such as
PR14059 is concerning. Those result in mismatched *sizes* of types in
addition to mismatched access and alloca types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165870 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/SROA.cpp
test/Transforms/SROA/alignment.ll
test/Transforms/SROA/basictest.ll