[PATCH] Remove conflicting attributes before adding deduced readonly/readnone
Phabricator
reviews at reviews.llvm.org
Mon May 25 12:50:36 PDT 2015
REPOSITORY
rL LLVM
http://reviews.llvm.org/D9995
Files:
llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/trunk/test/Transforms/FunctionAttrs/readnone.ll
Index: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
===================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -703,10 +703,14 @@
}
if (ReadAttr != Attribute::None) {
- AttrBuilder B;
+ AttrBuilder B, R;
B.addAttribute(ReadAttr);
+ R.addAttribute(Attribute::ReadOnly)
+ .addAttribute(Attribute::ReadNone);
for (unsigned i = 0, e = ArgumentSCC.size(); i != e; ++i) {
Argument *A = ArgumentSCC[i]->Definition;
+ // Clear out existing readonly/readnone attributes
+ A->removeAttr(AttributeSet::get(A->getContext(), A->getArgNo() + 1, R));
A->addAttr(AttributeSet::get(A->getContext(), A->getArgNo() + 1, B));
ReadAttr == Attribute::ReadOnly ? ++NumReadOnlyArg : ++NumReadNoneArg;
Changed = true;
Index: llvm/trunk/test/Transforms/FunctionAttrs/readnone.ll
===================================================================
--- llvm/trunk/test/Transforms/FunctionAttrs/readnone.ll
+++ llvm/trunk/test/Transforms/FunctionAttrs/readnone.ll
@@ -0,0 +1,13 @@
+; RUN: opt < %s -functionattrs -S | FileCheck %s
+
+; CHECK: define void @bar(i8* nocapture readnone)
+define void @bar(i8* readonly) {
+ call void @foo(i8* %0)
+ ret void
+}
+
+; CHECK: define void @foo(i8* nocapture readnone)
+define void @foo(i8* readonly) {
+ call void @bar(i8* %0)
+ ret void
+}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9995.26477.patch
Type: text/x-patch
Size: 1477 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150525/135b5b9e/attachment.bin>
More information about the llvm-commits
mailing list