diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h --- a/llvm/include/llvm/IR/InstrTypes.h +++ b/llvm/include/llvm/IR/InstrTypes.h @@ -1559,6 +1559,11 @@ Attrs = Attrs.removeFnAttribute(getContext(), Kind); } + /// Removes the attribute from the function + void removeFnAttr(StringRef Kind) { + Attrs = Attrs.removeFnAttribute(getContext(), Kind); + } + /// Removes the attribute from the return value void removeRetAttr(Attribute::AttrKind Kind) { Attrs = Attrs.removeRetAttribute(getContext(), Kind); diff --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp --- a/llvm/unittests/IR/InstructionsTest.cpp +++ b/llvm/unittests/IR/InstructionsTest.cpp @@ -102,6 +102,11 @@ Call->addRetAttr(Attribute::get(Call->getContext(), "test-str-attr")); EXPECT_TRUE(Call->hasRetAttr("test-str-attr")); EXPECT_FALSE(Call->hasRetAttr("not-on-call")); + + Call->addFnAttr(Attribute::get(Call->getContext(), "test-str-fn-attr")); + EXPECT_TRUE(Call->hasFnAttr("test-str-fn-attr")); + Call->removeFnAttr("test-str-fn-attr"); + EXPECT_FALSE(Call->hasFnAttr("test-str-fn-attr")); } TEST_F(ModuleWithFunctionTest, InvokeInst) {