diff options
author | Josh Stone <jistone@redhat.com> | 2019-04-23 23:43:47 +0000 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2019-04-23 23:43:47 +0000 |
commit | 27924c3a3c6744ec731fb49bda1bfc3a79442f7c (patch) | |
tree | 0080365a58604ad5e2d97b3826e9529f1238028d /llvm/lib/Analysis/Lint.cpp | |
parent | 4fe7574d5d5f86a3a218bd5943be6e1da99c7b9e (diff) | |
download | bcm5719-llvm-27924c3a3c6744ec731fb49bda1bfc3a79442f7c.tar.gz bcm5719-llvm-27924c3a3c6744ec731fb49bda1bfc3a79442f7c.zip |
[Lint] Permit aliasing noalias readonly arguments
Summary:
If two arguments are both readonly, then they have no memory dependency
that would violate noalias, even if they do actually overlap.
Reviewers: hfinkel, efriedma
Reviewed By: efriedma
Subscribers: efriedma, hiraditya, llvm-commits, tstellar
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60239
llvm-svn: 359047
Diffstat (limited to 'llvm/lib/Analysis/Lint.cpp')
-rw-r--r-- | llvm/lib/Analysis/Lint.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/Lint.cpp b/llvm/lib/Analysis/Lint.cpp index 37ce56d268b..d28b8a189d4 100644 --- a/llvm/lib/Analysis/Lint.cpp +++ b/llvm/lib/Analysis/Lint.cpp @@ -267,10 +267,14 @@ void Lint::visitCallSite(CallSite CS) { if (Formal->hasNoAliasAttr() && Actual->getType()->isPointerTy()) { AttributeList PAL = CS.getAttributes(); unsigned ArgNo = 0; - for (CallSite::arg_iterator BI = CS.arg_begin(); BI != AE; ++BI) { + for (CallSite::arg_iterator BI = CS.arg_begin(); BI != AE; + ++BI, ++ArgNo) { // Skip ByVal arguments since they will be memcpy'd to the callee's // stack so we're not really passing the pointer anyway. - if (PAL.hasParamAttribute(ArgNo++, Attribute::ByVal)) + if (PAL.hasParamAttribute(ArgNo, Attribute::ByVal)) + continue; + // If both arguments are readonly, they have no dependence. + if (Formal->onlyReadsMemory() && CS.onlyReadsMemory(ArgNo)) continue; if (AI != BI && (*BI)->getType()->isPointerTy()) { AliasResult Result = AA->alias(*AI, *BI); |