summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/ImplicitNullChecks.cpp
diff options
context:
space:
mode:
authorSerguei Katkov <serguei.katkov@azul.com>2017-08-09 05:17:02 +0000
committerSerguei Katkov <serguei.katkov@azul.com>2017-08-09 05:17:02 +0000
commit6ea2e81cf64b4362a22e8a64a61d3c29709b0d9b (patch)
treec54413b9a81288da6902b51a0f51ad79517d1fce /llvm/lib/CodeGen/ImplicitNullChecks.cpp
parent2a77b266b5f9eed7c81c02e28f273814cee27d74 (diff)
downloadbcm5719-llvm-6ea2e81cf64b4362a22e8a64a61d3c29709b0d9b.tar.gz
bcm5719-llvm-6ea2e81cf64b4362a22e8a64a61d3c29709b0d9b.zip
[ImplicitNullCheck] Fix the bug when dependent instruction accesses memory
It is possible that dependent instruction may access memory. In this case we must reject optimization because the memory change will be visible in null handler basic block. So we will execute an instruction which we must not execute if check fails. Reviewers: sanjoy, reames Reviewed By: sanjoy Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D36392 llvm-svn: 310443
Diffstat (limited to 'llvm/lib/CodeGen/ImplicitNullChecks.cpp')
-rw-r--r--llvm/lib/CodeGen/ImplicitNullChecks.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/ImplicitNullChecks.cpp b/llvm/lib/CodeGen/ImplicitNullChecks.cpp
index e308f49ec4e..e3dcffe6bae 100644
--- a/llvm/lib/CodeGen/ImplicitNullChecks.cpp
+++ b/llvm/lib/CodeGen/ImplicitNullChecks.cpp
@@ -390,8 +390,10 @@ bool ImplicitNullChecks::canHoistInst(MachineInstr *FaultingMI,
// We don't want to reason about speculating loads. Note -- at this point
// we should have already filtered out all of the other non-speculatable
// things, like calls and stores.
+ // We also do not want to hoist stores because it might change the memory
+ // while the FaultingMI may result in faulting.
assert(canHandle(DependenceMI) && "Should never have reached here!");
- if (DependenceMI->mayLoad())
+ if (DependenceMI->mayLoadOrStore())
return false;
for (auto &DependenceMO : DependenceMI->operands()) {
OpenPOWER on IntegriCloud