aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/StackProtector.cpp
diff options
context:
space:
mode:
authorNadav Rotem <nadav256@gmail.com>2020-07-27 10:06:36 -0700
committerNadav Rotem <nadav256@gmail.com>2020-07-27 10:07:47 -0700
commitdf880b77302d2e12d988e620eba242defdd6d4a7 (patch)
treefa0869f4289f6adc7e59e785c3169564778cb9b4 /llvm/lib/CodeGen/StackProtector.cpp
parent51e1c028d4021eba64a56e684d34bb164c244d43 (diff)
downloadllvm-df880b77302d2e12d988e620eba242defdd6d4a7.zip
llvm-df880b77302d2e12d988e620eba242defdd6d4a7.tar.gz
llvm-df880b77302d2e12d988e620eba242defdd6d4a7.tar.bz2
[StackProtector] Speed up RequiresStackProtector
Speed up the method RequiresStackProtector by checking the intrinsic value of the call. The original code calls getName() that returns an allocating std::string on each check. This change removes about 96072 std::string instances when compiling sqlite3.c; The function was discovered with a Facebook-internal performance tool. Differential Revision: https://reviews.llvm.org/D84620
Diffstat (limited to 'llvm/lib/CodeGen/StackProtector.cpp')
-rw-r--r--llvm/lib/CodeGen/StackProtector.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp
index a3437918..e246c2e 100644
--- a/llvm/lib/CodeGen/StackProtector.cpp
+++ b/llvm/lib/CodeGen/StackProtector.cpp
@@ -251,10 +251,9 @@ bool StackProtector::HasAddressTaken(const Instruction *AI,
static const CallInst *findStackProtectorIntrinsic(Function &F) {
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))
- return CI;
+ if (const auto *II = dyn_cast<IntrinsicInst>(&I))
+ if (II->getIntrinsicID() == Intrinsic::stackprotector)
+ return II;
return nullptr;
}