[GlobalOpt] Fix a miscompile when evaluating struct initializers.
authorJon Roelofs <jonathan_roelofs@apple.com>
Mon, 12 Jul 2021 19:43:45 +0000 (12:43 -0700)
committerJon Roelofs <jonathan_roelofs@apple.com>
Wed, 14 Jul 2021 22:37:01 +0000 (15:37 -0700)
commitd14310306827f5c0a4feb6a9ffddddcdfb24fcca
treea892fce92f1793255d44f46e4e7918efca4a3a48
parent483df573135f2287bfd1a6d5c4d7196036f13cbd
[GlobalOpt] Fix a miscompile when evaluating struct initializers.

The bug was that evaluateBitcastFromPtr attempts a narrowing to a struct's 0th
element of a store that covers other elements. While this is okay on the load
side, applying it to stores causes us to miss the writes to the additionally
covered elements.

rdar://79503568

Differential revision: https://reviews.llvm.org/D105838
llvm/lib/Transforms/Utils/Evaluator.cpp
llvm/test/Transforms/GlobalOpt/store-struct-element.ll [new file with mode: 0644]