[llvm] r316045 - [GlobalDCE] Use DenseMap instead of unordered_multimap for GVDependencies.
Michael Zolotukhin via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 17 16:47:06 PDT 2017
Author: mzolotukhin
Date: Tue Oct 17 16:47:06 2017
New Revision: 316045
URL: http://llvm.org/viewvc/llvm-project?rev=316045&view=rev
Log:
[GlobalDCE] Use DenseMap instead of unordered_multimap for GVDependencies.
Summary:
std::unordered_multimap happens to be very slow when the number of elements
grows large. On one of our internal applications we observed a 17x compile time
improvement from changing it to DenseMap.
Reviewers: mehdi_amini, serge-sans-paille, davide
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D38916
Modified:
llvm/trunk/include/llvm/Transforms/IPO/GlobalDCE.h
llvm/trunk/lib/Transforms/IPO/GlobalDCE.cpp
Modified: llvm/trunk/include/llvm/Transforms/IPO/GlobalDCE.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/GlobalDCE.h?rev=316045&r1=316044&r2=316045&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/IPO/GlobalDCE.h (original)
+++ llvm/trunk/include/llvm/Transforms/IPO/GlobalDCE.h Tue Oct 17 16:47:06 2017
@@ -35,7 +35,7 @@ private:
SmallPtrSet<GlobalValue*, 32> AliveGlobals;
/// Global -> Global that uses this global.
- std::unordered_multimap<GlobalValue *, GlobalValue *> GVDependencies;
+ DenseMap<GlobalValue *, SmallPtrSet<GlobalValue *, 4>> GVDependencies;
/// Constant -> Globals that use this global cache.
std::unordered_map<Constant *, SmallPtrSet<GlobalValue *, 8>>
Modified: llvm/trunk/lib/Transforms/IPO/GlobalDCE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalDCE.cpp?rev=316045&r1=316044&r2=316045&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalDCE.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalDCE.cpp Tue Oct 17 16:47:06 2017
@@ -115,7 +115,7 @@ void GlobalDCEPass::UpdateGVDependencies
ComputeDependencies(User, Deps);
Deps.erase(&GV); // Remove self-reference.
for (GlobalValue *GVU : Deps) {
- GVDependencies.insert(std::make_pair(GVU, &GV));
+ GVDependencies[GVU].insert(&GV);
}
}
@@ -199,8 +199,8 @@ PreservedAnalyses GlobalDCEPass::run(Mod
AliveGlobals.end()};
while (!NewLiveGVs.empty()) {
GlobalValue *LGV = NewLiveGVs.pop_back_val();
- for (auto &&GVD : make_range(GVDependencies.equal_range(LGV)))
- MarkLive(*GVD.second, &NewLiveGVs);
+ for (auto *GVD : GVDependencies[LGV])
+ MarkLive(*GVD, &NewLiveGVs);
}
// Now that all globals which are needed are in the AliveGlobals set, we loop
More information about the llvm-commits
mailing list