[llvm] 63a8ca3 - [LegacyPM] Call getPassName only when needed
Alexis Engelke via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 12 09:36:09 PDT 2023
Author: Alexis Engelke
Date: 2023-04-12T18:36:02+02:00
New Revision: 63a8ca3fe97d36ccd263f7d4ac18a9942b4d0333
URL: https://github.com/llvm/llvm-project/commit/63a8ca3fe97d36ccd263f7d4ac18a9942b4d0333
DIFF: https://github.com/llvm/llvm-project/commit/63a8ca3fe97d36ccd263f7d4ac18a9942b4d0333.diff
LOG: [LegacyPM] Call getPassName only when needed
Even when time tracing is disabled, getPassName is currently still
called. This adds an avoidable virtual function call for each pass.
Fetching the pass name only when required slightly improves
compile-time (particularly when LLVM is built without LTO).
Reviewed By: nikic, MaskRay
Differential Revision: https://reviews.llvm.org/D148022
Added:
Modified:
llvm/lib/IR/LegacyPassManager.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp
index ef3465177647..f9572cc2466c 100644
--- a/llvm/lib/IR/LegacyPassManager.cpp
+++ b/llvm/lib/IR/LegacyPassManager.cpp
@@ -1414,7 +1414,10 @@ bool FPPassManager::runOnFunction(Function &F) {
FunctionPass *FP = getContainedPass(Index);
bool LocalChanged = false;
- llvm::TimeTraceScope PassScope("RunPass", FP->getPassName());
+ // Call getPassName only when required. The call itself is fairly cheap, but
+ // still virtual and repeated calling adds unnecessary overhead.
+ llvm::TimeTraceScope PassScope(
+ "RunPass", [FP]() { return std::string(FP->getPassName()); });
dumpPassInfo(FP, EXECUTION_MSG, ON_FUNCTION_MSG, F.getName());
dumpRequiredSet(FP);
More information about the llvm-commits
mailing list