diff options
| author | Piotr Padlewski <piotr.padlewski@gmail.com> | 2018-05-18 23:54:33 +0000 |
|---|---|---|
| committer | Piotr Padlewski <piotr.padlewski@gmail.com> | 2018-05-18 23:54:33 +0000 |
| commit | 5642a42442f669208a88e8f9439904e1150c4688 (patch) | |
| tree | d1162fb9c6895f58fd3cd43feea214ca3711bf67 /llvm/lib/Analysis | |
| parent | ce358262eb7ddc3bf4b251c61feb87c561ad5378 (diff) | |
| download | bcm5719-llvm-5642a42442f669208a88e8f9439904e1150c4688.tar.gz bcm5719-llvm-5642a42442f669208a88e8f9439904e1150c4688.zip | |
Propagate nonnull and dereferenceable throught launder
Summary:
invariant.group.launder should not stop propagation
of nonnull and dereferenceable, because e.g. we would not be
able to hoist loads speculatively.
Reviewers: rsmith, amharc, kuhar, xbolva00, hfinkel
Subscribers: hiraditya, llvm-commits
Differential Revision: https://reviews.llvm.org/D46972
llvm-svn: 332788
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/Loads.cpp | 7 | ||||
| -rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp index 10a71de82e3..fda1395cf3e 100644 --- a/llvm/lib/Analysis/Loads.cpp +++ b/llvm/lib/Analysis/Loads.cpp @@ -107,11 +107,14 @@ static bool isDereferenceableAndAlignedPointer( return isDereferenceableAndAlignedPointer(ASC->getOperand(0), Align, Size, DL, CtxI, DT, Visited); - if (auto CS = ImmutableCallSite(V)) + if (auto CS = ImmutableCallSite(V)) { if (const Value *RV = CS.getReturnedArgOperand()) return isDereferenceableAndAlignedPointer(RV, Align, Size, DL, CtxI, DT, Visited); - + if (CS.getIntrinsicID() == Intrinsic::launder_invariant_group) + return isDereferenceableAndAlignedPointer(CS->getOperand(0), Align, Size, + DL, CtxI, DT, Visited); + } // If we don't know, assume the worst. return false; } diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 05246a28817..811c5016529 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -1953,9 +1953,12 @@ bool isKnownNonZero(const Value *V, unsigned Depth, const Query &Q) { if (LI->getMetadata(LLVMContext::MD_nonnull)) return true; - if (auto CS = ImmutableCallSite(V)) + if (auto CS = ImmutableCallSite(V)) { if (CS.isReturnNonNull()) return true; + if (CS.getIntrinsicID() == Intrinsic::ID::launder_invariant_group) + return isKnownNonZero(CS->getOperand(0), Depth + 1, Q); + } } // The remaining tests are all recursive, so bail out if we hit the limit. |

