From: Vedant Kumar Date: Thu, 22 Feb 2018 01:29:41 +0000 (+0000) Subject: [Utils] Avoid a hash table lookup in salvageDI, NFC X-Git-Tag: llvmorg-7.0.0-rc1~12302 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1ceabcf080b4e46681554a23273018b15576536c;p=platform%2Fupstream%2Fllvm.git [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. llvm-svn: 325738 --- diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index e75127f..7573fc3 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1486,6 +1486,11 @@ void llvm::replaceDbgValueForAlloca(AllocaInst *AI, Value *NewAllocaAddress, } 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 DbgUsers; findDbgUsers(DbgUsers, &I); if (DbgUsers.empty())