Commit 8447bbae by Andrew Scull

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.
parent cb6e95aa
...@@ -4698,8 +4698,8 @@ void TargetX86Base<Machine>::lowerSwitch(const InstSwitch *Inst) { ...@@ -4698,8 +4698,8 @@ void TargetX86Base<Machine>::lowerSwitch(const InstSwitch *Inst) {
SizeT Size; SizeT Size;
typename Traits::Insts::Label *Label; typename Traits::Insts::Label *Label;
}; };
std::stack<SearchSpan, std::deque<SearchSpan, CfgLocalAllocator<SearchSpan>>> // The stack will only grow to the height of the tree so 12 should be plenty
SearchSpanStack; std::stack<SearchSpan, llvm::SmallVector<SearchSpan, 12>> SearchSpanStack;
SearchSpanStack.emplace(0, CaseClusters.size(), nullptr); SearchSpanStack.emplace(0, CaseClusters.size(), nullptr);
bool DoneCmp = false; bool DoneCmp = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment