diff options
author | Vedant Kumar <vsk@apple.com> | 2018-06-26 18:44:52 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2018-06-26 18:44:52 +0000 |
commit | de46f65bbd2617851ff1dbd158cf5ee2944f1957 (patch) | |
tree | 164c38aed061afb5c10dfb8b1485a74c4b8d5e5e /llvm/lib/Transforms/Utils | |
parent | b7169c435af07dbe33ec79ddbdd24f961fb608b9 (diff) | |
download | bcm5719-llvm-de46f65bbd2617851ff1dbd158cf5ee2944f1957.tar.gz bcm5719-llvm-de46f65bbd2617851ff1dbd158cf5ee2944f1957.zip |
[Local] Sink salvageDI's early exit into helper functions, NFC
salvageDebugInfo() performs a check that allows it to exit early without
doing a DenseMap lookup. It's a bit neater and marginally more useful to
sink this early exit into the findDbg{Addr,Users,Values} helpers.
llvm-svn: 335642
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index d97c6b5c50a..756b60bb6fa 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1478,6 +1478,10 @@ void llvm::insertDebugValuesForPHIs(BasicBlock *BB, /// 'V' points to. This may include a mix of dbg.declare and /// dbg.addr intrinsics. TinyPtrVector<DbgInfoIntrinsic *> llvm::FindDbgAddrUses(Value *V) { + // This function is hot. Check whether the value has any metadata to avoid a + // DenseMap lookup. + if (!V->isUsedByMetadata()) + return {}; auto *L = LocalAsMetadata::getIfExists(V); if (!L) return {}; @@ -1496,6 +1500,10 @@ TinyPtrVector<DbgInfoIntrinsic *> llvm::FindDbgAddrUses(Value *V) { } void llvm::findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V) { + // This function is hot. Check whether the value has any metadata to avoid a + // DenseMap lookup. + if (!V->isUsedByMetadata()) + return; if (auto *L = LocalAsMetadata::getIfExists(V)) if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L)) for (User *U : MDV->users()) @@ -1505,6 +1513,10 @@ void llvm::findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V) { void llvm::findDbgUsers(SmallVectorImpl<DbgInfoIntrinsic *> &DbgUsers, Value *V) { + // This function is hot. Check whether the value has any metadata to avoid a + // DenseMap lookup. + if (!V->isUsedByMetadata()) + return; if (auto *L = LocalAsMetadata::getIfExists(V)) if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L)) for (User *U : MDV->users()) @@ -1579,11 +1591,6 @@ 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<DbgInfoIntrinsic *, 1> DbgUsers; findDbgUsers(DbgUsers, &I); if (DbgUsers.empty()) |