IfConversion non-recursive patch
Nick Lewycky
nicholas at mxc.ca
Wed Jul 10 10:59:32 PDT 2013
Andrew Zhogin wrote:
> Hi all.
>
> I want to propose patch for making IfConversion analyze algorithm
> non-recursive.
>
> Recursive algorithm causes running out of stack space on our system on
> huge functions (with many BasicBlocks).
>
> Could anyone review and apply it?
+ std::stack<MachineBasicBlock *> ParentStack;
+ std::stack<MachineBasicBlock *> ForwardStack;
+ IfConverter &Parent;
+ std::vector<IfConverter::IfcvtToken*> &Tokens;
LLVM has its own ADTs. Please review
http://llvm.org/docs/ProgrammersManual.html#picking-the-right-data-structure-for-a-task
and pick some. The most common is to use SmallVector which offers a
combined "pop_back_val()" method.
+ inline MachineBasicBlock *ExtractFromParent() {
[...]
+ MachineBasicBlock * tmp = ParentStack.top();
[...]
+ if (MachineBasicBlock* extracted = ExtractFromForward()) {
Please be consistent about the placement of the '*' (or '&') versus
whitespace. The common style in this file is "Type *variable".
+ if (Parent.ValidSimple(FalseBBI, Dups, Prediction.getCompl()) &&
+ Parent.MeetIfcvtSizeLimit(*FalseBBI.BB,
FalseBBI.NonPredSize + FalseBBI.ExtraCost,
FalseBBI.ExtraCost2, Prediction.getCompl()) &&
Because you adjusted the position of the ( after MeetIfcvtSizeLimit, you
also need to adjust the spacing on the lines that follow it. You may
want to consider using clang-format.
Nick
More information about the llvm-commits
mailing list