Fix a long-standing miscompile in the load analysis that was uncovered
authorChandler Carruth <chandlerc@gmail.com>
Sun, 19 Oct 2014 08:17:50 +0000 (08:17 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sun, 19 Oct 2014 08:17:50 +0000 (08:17 +0000)
commita801dd5799bd6f6641ce3a7ea48f32d274ef95a0
tree560a472c66fbfae4ebb35d7040168d6787b365a2
parent0c28bc20da65169dac6133be5e230b7c5c0914c1
Fix a long-standing miscompile in the load analysis that was uncovered
by my refactoring of this code.

The method isSafeToLoadUnconditionally assumes that the load will
proceed with the preferred type alignment. Given that, it has to ensure
that the alloca or global is at least that aligned. It has always done
this historically when a datalayout is present, but has never checked it
when the datalayout is absent. When I refactored the code in r220156,
I exposed this path when datalayout was present and that turned the
latent bug into a patent bug.

This fixes the issue by just removing the special case which allows
folding things without datalayout. This isn't worth the complexity of
trying to tease apart when it is or isn't safe without actually knowing
the preferred alignment.

llvm-svn: 220161
llvm/lib/Analysis/Loads.cpp
llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
llvm/test/Transforms/InstCombine/load.ll
llvm/test/Transforms/InstCombine/select.ll
llvm/test/Transforms/TailCallElim/reorder_load.ll