[PATCH] D117624: [NFC] MemoryBuiltins: tease out a getFreeFunctionDataForFunction helper
Augie Fackler via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 18 16:11:53 PST 2022
durin42 created this revision.
Herald added a subscriber: hiraditya.
durin42 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
I'll need this in my next change.
Depends on D117350 <https://reviews.llvm.org/D117350>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117624
Files:
llvm/lib/Analysis/MemoryBuiltins.cpp
Index: llvm/lib/Analysis/MemoryBuiltins.cpp
===================================================================
--- llvm/lib/Analysis/MemoryBuiltins.cpp
+++ llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -43,6 +43,7 @@
#include <cassert>
#include <cstdint>
#include <iterator>
+#include <type_traits>
#include <utility>
using namespace llvm;
@@ -434,16 +435,22 @@
};
// clang-format on
-/// isLibFreeFunction - Returns true if the function is a builtin free()
-bool llvm::isLibFreeFunction(const Function *F, const LibFunc TLIFn) {
+Optional<FreeFnsTy> getFreeFunctionDataForFunction(const Function *Callee,
+ const LibFunc TLIFn) {
const auto *Iter =
find_if(FreeFnData, [TLIFn](const std::pair<LibFunc, FreeFnsTy> &P) {
return P.first == TLIFn;
});
- if (Iter == std::end(FreeFnData)) {
+ if (Iter == std::end(FreeFnData))
+ return None;
+ return Iter->second;
+}
+
+/// isLibFreeFunction - Returns true if the function is a builtin free()
+bool llvm::isLibFreeFunction(const Function *F, const LibFunc TLIFn) {
+ Optional<FreeFnsTy> FnData = getFreeFunctionDataForFunction(F, TLIFn);
+ if (!FnData.hasValue())
return false;
- }
- const FreeFnsTy *FnData = &Iter->second;
// Check free prototype.
// FIXME: workaround for PR5130, this will be obsolete when a nobuiltin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117624.401030.patch
Type: text/x-patch
Size: 1374 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220119/8091b7a5/attachment.bin>
More information about the llvm-commits
mailing list