Skip to content

Commit

Permalink
Using a deque to manage the stack of nodes is faster here.
Browse files Browse the repository at this point in the history
  Vector is slow due to many reallocations as the size regularly changes in
  unpredictable ways. See the investigation provided on the mailing list for
  more information:

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120116/135228.html


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218182 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
ldm5180 committed Sep 20, 2014
1 parent 3f34ae9 commit 31235e5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Transforms/Scalar/EarlyCSE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "llvm/Support/RecyclingAllocator.h"
#include "llvm/Target/TargetLibraryInfo.h"
#include "llvm/Transforms/Utils/Local.h"
#include <vector>
#include <deque>
using namespace llvm;

#define DEBUG_TYPE "early-cse"
Expand Down Expand Up @@ -560,7 +560,11 @@ bool EarlyCSE::runOnFunction(Function &F) {
if (skipOptnoneFunction(F))
return false;

std::vector<StackNode *> nodesToProcess;
// Note, deque is being used here because there is significant performance gains
// over vector when the container becomes very large due to the specific access
// patterns. For more information see the mailing list discussion on this:
// http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120116/135228.html
std::deque<StackNode *> nodesToProcess;

DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
DL = DLP ? &DLP->getDataLayout() : nullptr;
Expand Down

0 comments on commit 31235e5

Please sign in to comment.