summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2015-05-06 23:54:14 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2015-05-06 23:54:14 +0000
commit3058d0f08026583f1db33a040eac0f8f654dff41 (patch)
treed9b0454cc98a1d3b808dc8b2e5740c3915daaef8 /llvm/lib/IR/Function.cpp
parent2e0d29fb09f7d559616bc756709630c14d31677e (diff)
downloadbcm5719-llvm-3058d0f08026583f1db33a040eac0f8f654dff41.tar.gz
bcm5719-llvm-3058d0f08026583f1db33a040eac0f8f654dff41.zip
Let llc and opt override "-target-cpu" and "-target-features" via command line
options. This commit fixes a bug in llc and opt where "-mcpu" and "-mattr" wouldn't override function attributes "-target-cpu" and "-target-features" in the IR. Differential Revision: http://reviews.llvm.org/D9537 llvm-svn: 236677
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index aea4bf52701..d896eea5803 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -975,3 +975,16 @@ void Function::setPrologueData(Constant *PrologueData) {
}
setValueSubclassData(PDData);
}
+
+void llvm::overrideFunctionAttribute(StringRef Kind, StringRef Value,
+ Function &F) {
+ auto &Ctx = F.getContext();
+ AttributeSet Attrs = F.getAttributes(), AttrsToRemove;
+
+ AttrsToRemove =
+ AttrsToRemove.addAttribute(Ctx, AttributeSet::FunctionIndex, Kind);
+ Attrs = Attrs.removeAttributes(Ctx, AttributeSet::FunctionIndex,
+ AttrsToRemove);
+ Attrs = Attrs.addAttribute(Ctx, AttributeSet::FunctionIndex, Kind, Value);
+ F.setAttributes(Attrs);
+}
OpenPOWER on IntegriCloud