diff --git a/llvm/lib/Analysis/Lint.cpp b/llvm/lib/Analysis/Lint.cpp --- a/llvm/lib/Analysis/Lint.cpp +++ b/llvm/lib/Analysis/Lint.cpp @@ -235,6 +235,10 @@ // If both arguments are readonly, they have no dependence. if (Formal->onlyReadsMemory() && I.onlyReadsMemory(ArgNo)) continue; + // Skip readnone arguments since those are guaranteed not to be + // dereferenced anyway. + if (F->hasParamAttribute(ArgNo, Attribute::ReadNone)) + continue; if (AI != BI && (*BI)->getType()->isPointerTy()) { AliasResult Result = AA->alias(*AI, *BI); Check(Result != AliasResult::MustAlias && diff --git a/llvm/test/Analysis/Lint/noalias-readnone.ll b/llvm/test/Analysis/Lint/noalias-readnone.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Analysis/Lint/noalias-readnone.ll @@ -0,0 +1,14 @@ +; RUN: opt < %s -passes=lint -disable-output 2>&1 | FileCheck %s + +declare void @foo1(ptr noalias, ptr readnone) + +define void @test1(ptr %a) { +entry: + call void @foo1(ptr %a, ptr %a) + ret void +} + +; Lint should not complain about passing %a to both arguments even if one is +; noalias, since the second argument is readnone. +; CHECK-NOT: Unusual: noalias argument aliases another argument +; CHECK-NOT: call void @foo1(ptr %a, ptr %a)