summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/TargetOptionsImpl.cpp20
-rw-r--r--llvm/lib/IR/Function.cpp13
2 files changed, 20 insertions, 13 deletions
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);
+ }
+}
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index cbba2ee90a1..c579b6bf1b1 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -959,19 +959,6 @@ 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);
-}
-
void Function::setEntryCount(uint64_t Count) {
MDBuilder MDB(getContext());
setMetadata(LLVMContext::MD_prof, MDB.createFunctionEntryCount(Count));
OpenPOWER on IntegriCloud