[PATCH] D148022: [LegacyPM] Call getPassName only when needed

Alexis Engelke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 08:42:51 PDT 2023


aengelke updated this revision to Diff 512478.
aengelke added a comment.

Format changes + re-trigger CI


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148022/new/

https://reviews.llvm.org/D148022

Files:
  llvm/lib/IR/LegacyPassManager.cpp


Index: llvm/lib/IR/LegacyPassManager.cpp
===================================================================
--- llvm/lib/IR/LegacyPassManager.cpp
+++ llvm/lib/IR/LegacyPassManager.cpp
@@ -1414,7 +1414,10 @@
     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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148022.512478.patch
Type: text/x-patch
Size: 715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230411/a99086a8/attachment.bin>


More information about the llvm-commits mailing list