[llvm] r325738 - [Utils] Avoid a hash table lookup in salvageDI, NFC

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 21 17:29:42 PST 2018


Author: vedantk
Date: Wed Feb 21 17:29:41 2018
New Revision: 325738

URL: http://llvm.org/viewvc/llvm-project?rev=325738&view=rev
Log:
[Utils] Avoid a hash table lookup in salvageDI, NFC

According to the current coverage report salvageDebugInfo() is called
5.12 million times during testing and almost always returns early.

The early return depends on LocalAsMetadata::getIfExists returning null,
which involves a DenseMap lookup in an LLVMContextImpl. We can probably
speed this up by simply checking the IsUsedByMD bit in Value.

Modified:
    llvm/trunk/lib/Transforms/Utils/Local.cpp

Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=325738&r1=325737&r2=325738&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Wed Feb 21 17:29:41 2018
@@ -1486,6 +1486,11 @@ void llvm::replaceDbgValueForAlloca(Allo
 }
 
 void llvm::salvageDebugInfo(Instruction &I) {
+  // This function is hot. An early check to determine whether the instruction
+  // has any metadata to save allows it to return earlier on average.
+  if (!I.isUsedByMetadata())
+    return;
+
   SmallVector<DbgInfoIntrinsic *, 1> DbgUsers;
   findDbgUsers(DbgUsers, &I);
   if (DbgUsers.empty())




More information about the llvm-commits mailing list