[PATCH] D149192: [IR] Add interface to remove a CallBase string function attribute
Teresa Johnson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 25 14:13:54 PDT 2023
tejohnson created this revision.
tejohnson added a reviewer: snehasish.
Herald added a project: All.
tejohnson requested review of this revision.
Herald added a project: LLVM.
Adds an interface to remove a string function attribute attached to a
CallBase, and a corresponding unittest.
This was extracted from D141077 <https://reviews.llvm.org/D141077>, and will be used by a follow on patch
that removes memprof attributes when needed.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D149192
Files:
llvm/include/llvm/IR/InstrTypes.h
llvm/unittests/IR/InstructionsTest.cpp
Index: llvm/unittests/IR/InstructionsTest.cpp
===================================================================
--- llvm/unittests/IR/InstructionsTest.cpp
+++ 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) {
Index: llvm/include/llvm/IR/InstrTypes.h
===================================================================
--- llvm/include/llvm/IR/InstrTypes.h
+++ 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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149192.516903.patch
Type: text/x-patch
Size: 1259 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230425/4d39033e/attachment.bin>
More information about the llvm-commits
mailing list