[llvm] r302819 - [LiveVariables] Switch Kill/Defs sets to be DenseSet(s).

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Thu May 11 12:37:44 PDT 2017


Author: davide
Date: Thu May 11 14:37:43 2017
New Revision: 302819

URL: http://llvm.org/viewvc/llvm-project?rev=302819&view=rev
Log:
[LiveVariables] Switch Kill/Defs sets to be DenseSet(s).

The testcase in PR32984 shows a non linear compile time increase
after a change that made the LoopUnroll pass more aggressive
(increasing the threshold).

My profiling shows all the time of PHI elimination goes to
llvm::LiveVariables::addNewBlock. This is because we keep
Defs/Kills registers in a SmallSet and vfind(const T &V); is O(N).

Switching to a DenseSet reduces the time spent in the pass from
297 seconds to 97 seconds. Profiling still shows a lot of time is
spent iterating the data structure, so I guess there's room for
improvement.

Dan tells me GCC uses real set operations for live registers and
it takes no-time on this testcase. Matthias points out we might
want to switch all this to LiveIntervalAnalysis so it's not entirely
sure if a rewrite is worth it.

Differential Revision:  https://reviews.llvm.org/D33088

Modified:
    llvm/trunk/lib/CodeGen/LiveVariables.cpp

Modified: llvm/trunk/lib/CodeGen/LiveVariables.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveVariables.cpp?rev=302819&r1=302818&r2=302819&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveVariables.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveVariables.cpp Thu May 11 14:37:43 2017
@@ -767,7 +767,7 @@ void LiveVariables::addNewBlock(MachineB
                                 MachineBasicBlock *SuccBB) {
   const unsigned NumNew = BB->getNumber();
 
-  SmallSet<unsigned, 16> Defs, Kills;
+  DenseSet<unsigned> Defs, Kills;
 
   MachineBasicBlock::iterator BBI = SuccBB->begin(), BBE = SuccBB->end();
   for (; BBI != BBE && BBI->isPHI(); ++BBI) {




More information about the llvm-commits mailing list