summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorBjorn Steinbrink <bsteinbr@gmail.com>2015-05-25 19:46:38 +0000
committerBjorn Steinbrink <bsteinbr@gmail.com>2015-05-25 19:46:38 +0000
commit236446cd4c32233f42f513a552bbcc29de020ff4 (patch)
treedb1cc8f3b48b8d74c17162480670f67a22b50de1 /llvm/lib/Transforms
parentf071bd0a18873098507fe2728f8eb96338896a2a (diff)
downloadbcm5719-llvm-236446cd4c32233f42f513a552bbcc29de020ff4.tar.gz
bcm5719-llvm-236446cd4c32233f42f513a552bbcc29de020ff4.zip
Remove conflicting attributes before adding deduced readonly/readnone
Summary: In case of functions that have a pointer argument and only pass it to each other, the function attributes pass deduces that the pointer should get the readnone attribute, but fails to remove a readonly attribute that may already have been present. Reviewers: nlewycky Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9995 llvm-svn: 238152
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionAttrs.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index 0166935e722..92e384a340a 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -703,10 +703,14 @@ bool FunctionAttrs::AddArgumentAttrs(const CallGraphSCC &SCC) {
}
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;
OpenPOWER on IntegriCloud