]> granicus.if.org Git - llvm/commit
Reapply "[GVN] Prevent LoadPRE from hoisting across instructions that don't pass...
authorMax Kazantsev <max.kazantsev@azul.com>
Tue, 31 Oct 2017 05:07:56 +0000 (05:07 +0000)
committerMax Kazantsev <max.kazantsev@azul.com>
Tue, 31 Oct 2017 05:07:56 +0000 (05:07 +0000)
commit057fc35f6fd7ddb9aa48e082ed42f205ccf13c98
treebe0865ed15a41163d97221b4138556e8b7ed603c
parent933b96c6fcc59372fb3b21970eb9e092aa592904
Reapply "[GVN] Prevent LoadPRE from hoisting across instructions that don't pass control flow to successors"

This patch fixes the miscompile that happens when PRE hoists loads across guards and
other instructions that don't always pass control flow to their successors. PRE is now prohibited
to hoist across such instructions because there is no guarantee that the load standing after such
instruction is still valid before such instruction. For example, a load from under a guard may be
invalid before the guard in the following case:
  int array[LEN];
  ...
  guard(0 <= index && index < LEN);
  use(array[index]);

Differential Revision: https://reviews.llvm.org/D37460

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316975 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Transforms/Scalar/GVN.h
lib/Transforms/Scalar/GVN.cpp
test/Transforms/GVN/PRE/2017-10-16-LoadPRECrash.ll
test/Transforms/GVN/PRE/pre-load-guards.ll [new file with mode: 0644]
test/Transforms/GVN/PRE/pre-load-implicit-cf-updates.ll [new file with mode: 0644]
test/Transforms/GVN/PRE/pre-load.ll