summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/ImplicitNullChecks.cpp
diff options
context:
space:
mode:
authorYichao Yu <yyc1992@gmail.com>2017-10-17 11:47:36 +0000
committerYichao Yu <yyc1992@gmail.com>2017-10-17 11:47:36 +0000
commita18b0b181755a6dc7b50b8caa48758907364aaf8 (patch)
tree0aa8da58727b510e465975cb8d6c6087a84edecb /llvm/lib/CodeGen/ImplicitNullChecks.cpp
parenta46eb8e6490f72dd3510a93ece78d0919e19702c (diff)
downloadbcm5719-llvm-a18b0b181755a6dc7b50b8caa48758907364aaf8.tar.gz
bcm5719-llvm-a18b0b181755a6dc7b50b8caa48758907364aaf8.zip
Fix implicit null check with negative offset
Summary: It seems that negative offset was accidentally allowed in D17967. AFAICT small negative offset should be valid (always raise segfault) on all archs that I'm aware of (especially x86, which is the only one with this optimization enabled) and such case can be useful when loading hiden metadata from an object. However, like the positive side, it should only be done within a certain limit. For now, use the same limit on the positive side for the negative side. A separate option can be added if needs appear. Reviewers: mcrosier, skatkov Reviewed By: skatkov Subscribers: sanjoy, llvm-commits Differential Revision: https://reviews.llvm.org/D38925 llvm-svn: 315991
Diffstat (limited to 'llvm/lib/CodeGen/ImplicitNullChecks.cpp')
-rw-r--r--llvm/lib/CodeGen/ImplicitNullChecks.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/ImplicitNullChecks.cpp b/llvm/lib/CodeGen/ImplicitNullChecks.cpp
index 19c52d01374..bf0f88d49a8 100644
--- a/llvm/lib/CodeGen/ImplicitNullChecks.cpp
+++ b/llvm/lib/CodeGen/ImplicitNullChecks.cpp
@@ -369,7 +369,7 @@ ImplicitNullChecks::isSuitableMemoryOp(MachineInstr &MI, unsigned PointerReg,
// We want the mem access to be issued at a sane offset from PointerReg,
// so that if PointerReg is null then the access reliably page faults.
if (!((MI.mayLoad() || MI.mayStore()) && !MI.isPredicable() &&
- Offset < PageSize))
+ -PageSize < Offset && Offset < PageSize))
return SR_Unsuitable;
// Finally, check whether the current memory access aliases with previous one.
OpenPOWER on IntegriCloud