[LLVMdev] mem2reg Question

Eli Friedman eli.friedman at gmail.com
Fri Sep 19 15:17:56 PDT 2008


On Fri, Sep 19, 2008 at 11:08 AM, David Greene <dag at cray.com> wrote:
> \Why is this only prevented when NOT storing
> to global values?

It's not a question of storing *to* a global value, but storing a
global value into the alloca.  If there's only a single store to an
alloca, there are only two possible values that can be extracted from
the alloca: the value stored, and undef.  Assuming it's well-defined,
it's always correct to use the value stored, because undef can be
anything.

The reason for the check is question is that the stored value might
not dominate the use.  This is only possible, however, if the stored
value is an instruction; dominance doesn't make sense if
StoringGlobalVal is true.

-Eli



More information about the llvm-dev mailing list