diff options
author | Anna Thomas <anna@azul.com> | 2020-09-10 13:14:44 -0400 |
---|---|---|
committer | Anna Thomas <anna@azul.com> | 2020-09-10 13:39:50 -0400 |
commit | 46329f6079da99133eab7942e79226b2afb40e75 (patch) | |
tree | 3a0e3131143285dd41cfdbeecabb27fe38cd1548 /llvm/lib/CodeGen/ImplicitNullChecks.cpp | |
parent | b85c085c846c2cb5d24812555847846877ca13cb (diff) | |
download | llvm-46329f6079da99133eab7942e79226b2afb40e75.zip llvm-46329f6079da99133eab7942e79226b2afb40e75.tar.gz llvm-46329f6079da99133eab7942e79226b2afb40e75.tar.bz2 |
[ImplicitNullCheck] Handle instructions that preserve zero value
This is the first in a series of patches to make implicit null checks
more general. This patch identifies instructions that preserves zero
value of a register and considers that as a valid instruction to hoist
along with the faulting load. See added testcases.
Reviewed-By: reames, dantrushin
Differential Revision: https://reviews.llvm.org/D87108
Diffstat (limited to 'llvm/lib/CodeGen/ImplicitNullChecks.cpp')
-rw-r--r-- | llvm/lib/CodeGen/ImplicitNullChecks.cpp | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/ImplicitNullChecks.cpp b/llvm/lib/CodeGen/ImplicitNullChecks.cpp index dc1b0a8..8e1f9c3 100644 --- a/llvm/lib/CodeGen/ImplicitNullChecks.cpp +++ b/llvm/lib/CodeGen/ImplicitNullChecks.cpp @@ -435,12 +435,6 @@ bool ImplicitNullChecks::canDependenceHoistingClobberLiveIns( if (AnyAliasLiveIn(TRI, NullSucc, DependenceMO.getReg())) return true; - // The Dependency can't be re-defining the base register -- then we won't - // get the memory operation on the address we want. This is already - // checked in \c IsSuitableMemoryOp. - assert(!(DependenceMO.isDef() && - TRI->regsOverlap(DependenceMO.getReg(), PointerReg)) && - "Should have been checked before!"); } // The dependence does not clobber live-ins in NullSucc block. @@ -628,11 +622,9 @@ bool ImplicitNullChecks::analyzeBlockForNullChecks( return true; } - // If MI re-defines the PointerReg then we cannot move further. - if (llvm::any_of(MI.operands(), [&](MachineOperand &MO) { - return MO.isReg() && MO.getReg() && MO.isDef() && - TRI->regsOverlap(MO.getReg(), PointerReg); - })) + // If MI re-defines the PointerReg in a way that changes the value of + // PointerReg if it was null, then we cannot move further. + if (!TII->preservesZeroValueInReg(&MI, PointerReg, TRI)) return false; InstsSeenSoFar.push_back(&MI); } |