[PATCH] D84620: [StackProtector] Speed up RequiresStackProtector
Nadav Rotem via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 26 23:30:19 PDT 2020
nadav created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
Speed up the method RequiresStackProtector by saving the value of
Intrinsic::getDeclaration. This method calls getName() that returns an
allocating std::string. This change removes about 96072 std::string instances
when compiling sqlite3.c; The function was discovered with a Facebook-internal
performance tool.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D84620
Files:
llvm/lib/CodeGen/StackProtector.cpp
Index: llvm/lib/CodeGen/StackProtector.cpp
===================================================================
--- llvm/lib/CodeGen/StackProtector.cpp
+++ llvm/lib/CodeGen/StackProtector.cpp
@@ -249,11 +249,12 @@
/// Search for the first call to the llvm.stackprotector intrinsic and return it
/// if present.
static const CallInst *findStackProtectorIntrinsic(Function &F) {
+ Function *StackProtectorDecl =
+ Intrinsic::getDeclaration(F.getParent(), Intrinsic::stackprotector);
for (const BasicBlock &BB : F)
for (const Instruction &I : BB)
if (const CallInst *CI = dyn_cast<CallInst>(&I))
- if (CI->getCalledFunction() ==
- Intrinsic::getDeclaration(F.getParent(), Intrinsic::stackprotector))
+ if (CI->getCalledFunction() == StackProtectorDecl)
return CI;
return nullptr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84620.280791.patch
Type: text/x-patch
Size: 842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200727/e2ac4884/attachment.bin>
More information about the llvm-commits
mailing list