From bd881834c5eeb75f1e5cd8a0d56c25dfe122daa5 Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Sat, 23 May 2015 01:12:26 +0000 Subject: Simplify and rename function overrideFunctionAttributes. NFC. This is in preparation to making changes needed to stop resetting NoFramePointerElim in resetTargetOptions. llvm-svn: 238079 --- llvm/lib/CodeGen/TargetOptionsImpl.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'llvm/lib/CodeGen') diff --git a/llvm/lib/CodeGen/TargetOptionsImpl.cpp b/llvm/lib/CodeGen/TargetOptionsImpl.cpp index 3ca2017550c..c855ae51ce4 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); + } +} -- cgit v1.2.3