From ae3cfeb3ad0e4d3d8846d83c4b75e2933f043800 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Tue, 11 Sep 2018 11:51:29 +0000 Subject: [FuncAttrs] Remove "access range attributes" for read-none functions The presence of readnone and an access range attribute (argmemonly, inaccessiblememonly, inaccessiblemem_or_argmemonly) is considered an error by the verifier. This seems strict but also not wrong. This patch makes sure function attribute detection will remove all access range attributes for readnone functions. llvm-svn: 341927 --- llvm/lib/Transforms/IPO/FunctionAttrs.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp index d40ee30f453..72c850fca99 100644 --- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp @@ -281,6 +281,13 @@ static bool addReadAttrs(const SCCNodeSet &SCCNodes, AARGetterT &&AARGetter) { F->removeFnAttr(Attribute::ReadNone); F->removeFnAttr(Attribute::WriteOnly); + if (!WritesMemory && !ReadsMemory) { + // Clear out any "access range attributes" if readnone was deduced. + F->removeFnAttr(Attribute::ArgMemOnly); + F->removeFnAttr(Attribute::InaccessibleMemOnly); + F->removeFnAttr(Attribute::InaccessibleMemOrArgMemOnly); + } + // Add in the new attribute. if (WritesMemory && !ReadsMemory) F->addFnAttr(Attribute::WriteOnly); -- cgit v1.2.3