Avoid heap allocation for binary search work stack.
During switch lowering a binary search tree is created. The height of this
tree is usually small so no need for heap allocation.
BUG=
R=jvoung@chromium.org, jvoung, stichnot
Review URL: https://codereview.chromium.org/1240323005.
diff --git a/src/IceTargetLoweringX86BaseImpl.h b/src/IceTargetLoweringX86BaseImpl.h
index fc0a8e2..77048b0 100644
--- a/src/IceTargetLoweringX86BaseImpl.h
+++ b/src/IceTargetLoweringX86BaseImpl.h
@@ -4698,8 +4698,8 @@
SizeT Size;
typename Traits::Insts::Label *Label;
};
- std::stack<SearchSpan, std::deque<SearchSpan, CfgLocalAllocator<SearchSpan>>>
- SearchSpanStack;
+ // The stack will only grow to the height of the tree so 12 should be plenty
+ std::stack<SearchSpan, llvm::SmallVector<SearchSpan, 12>> SearchSpanStack;
SearchSpanStack.emplace(0, CaseClusters.size(), nullptr);
bool DoneCmp = false;