[GlobalOpt] recompute alignments for loads and stores of updated globals
authorSanjay Patel <spatel@rotateright.com>
Thu, 20 May 2021 15:32:03 +0000 (11:32 -0400)
committerSanjay Patel <spatel@rotateright.com>
Thu, 20 May 2021 16:12:21 +0000 (12:12 -0400)
commitf34311c4024d07246128352241ff360173c68f87
treebe1d61e5c9fac289613799fc1aaeffcd99b756a2
parentee4055cf23e7c7c5e2b91aefbbf10aa23754ade9
[GlobalOpt] recompute alignments for loads and stores of updated globals

GlobalOpt can slice structs/arrays and change GEPs in the process,
but it was not updating alignments for load/store users. This
eventually causes the crashing seen in:
https://llvm.org/PR49661
https://llvm.org/PR50253

On x86, this required SLP+codegen to create an aligned vector
store on an invalid address. The bugs would be easier to
demonstrate on a target with stricter alignment requirements.

I'm not sure if this is a complete solution. The alignment
updating code is adapted from InstCombine, so I assume that
part is tested and good.

Differential Revision: https://reviews.llvm.org/D102552
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/test/Transforms/GlobalOpt/externally-initialized-global-ctr.ll
llvm/test/Transforms/GlobalOpt/globalsra-align.ll