summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
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