aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetOptionsImpl.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2015-05-23 01:12:26 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2015-05-23 01:12:26 +0000
commitbd881834c5eeb75f1e5cd8a0d56c25dfe122daa5 (patch)
treed137183a4ce14e9fbdc74e7d7da83c584b92709a /llvm/lib/CodeGen/TargetOptionsImpl.cpp
parent20e9bcbfc8817eb9a4c2433830a571430b7321e8 (diff)
downloadllvm-bd881834c5eeb75f1e5cd8a0d56c25dfe122daa5.zip
llvm-bd881834c5eeb75f1e5cd8a0d56c25dfe122daa5.tar.gz
llvm-bd881834c5eeb75f1e5cd8a0d56c25dfe122daa5.tar.bz2
Simplify and rename function overrideFunctionAttributes. NFC.
This is in preparation to making changes needed to stop resetting NoFramePointerElim in resetTargetOptions. llvm-svn: 238079
Diffstat (limited to 'llvm/lib/CodeGen/TargetOptionsImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetOptionsImpl.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TargetOptionsImpl.cpp b/llvm/lib/CodeGen/TargetOptionsImpl.cpp
index 3ca2017..c855ae5 100644
--- a/llvm/lib/CodeGen/TargetOptionsImpl.cpp
+++ b/llvm/lib/CodeGen/TargetOptionsImpl.cpp
@@ -51,3 +51,23 @@ bool TargetOptions::HonorSignDependentRoundingFPMath() const {
StringRef TargetOptions::getTrapFunctionName() const {
return TrapFuncName;
}
+
+
+void llvm::setFunctionAttributes(StringRef CPU, StringRef Features, Module &M) {
+ for (auto &F : M) {
+ auto &Ctx = F.getContext();
+ AttributeSet Attrs = F.getAttributes(), NewAttrs;
+
+ if (!CPU.empty())
+ NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,
+ "target-cpu", CPU);
+
+ if (!Features.empty())
+ NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,
+ "target-features", Features);
+
+ // Let NewAttrs override Attrs.
+ NewAttrs = Attrs.addAttributes(Ctx, AttributeSet::FunctionIndex, NewAttrs);
+ F.setAttributes(NewAttrs);
+ }
+}