[llvm] 235fb60 - [MemoryBuiltins] Don't query TLI for non-pointer functions (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 21 02:28:49 PDT 2022
Author: Nikita Popov
Date: 2022-07-21T11:28:36+02:00
New Revision: 235fb602ed99c59f2a741533906c19280d791e18
URL: https://github.com/llvm/llvm-project/commit/235fb602ed99c59f2a741533906c19280d791e18
DIFF: https://github.com/llvm/llvm-project/commit/235fb602ed99c59f2a741533906c19280d791e18.diff
LOG: [MemoryBuiltins] Don't query TLI for non-pointer functions (NFC)
Fetching allocation data for calls is a rather hot operation, and
TLI lookups are slow. We can greatly reduce the number of calls
for which TLI is queried by checking that they return a pointer
value first, as this is a requirement for allocation functions
anyway.
Added:
Modified:
llvm/lib/Analysis/MemoryBuiltins.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp
index 5c9f9cc94fd1..50256a2629d4 100644
--- a/llvm/lib/Analysis/MemoryBuiltins.cpp
+++ b/llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -179,6 +179,11 @@ static const Function *getCalledFunction(const Value *V,
static Optional<AllocFnsTy>
getAllocationDataForFunction(const Function *Callee, AllocType AllocTy,
const TargetLibraryInfo *TLI) {
+ // Don't perform a slow TLI lookup, if this function doesn't return a pointer
+ // and thus can't be an allocation function.
+ if (!Callee->getReturnType()->isPointerTy())
+ return None;
+
// Make sure that the function is available.
LibFunc TLIFn;
if (!TLI || !TLI->getLibFunc(*Callee, TLIFn) || !TLI->has(TLIFn))
More information about the llvm-commits
mailing list