This was not removing the block from the live set depending on the
specific depth first visit order. Fixes a verifier error in the OpenCL
conformance tests.
Details
Diff Detail
Event Timeline
llvm/lib/Target/AMDGPU/SIOptimizeVGPRLiveRange.cpp | ||
---|---|---|
386–387 | A pre-order walk over the blocks should more match the need here. the dfs walk does not work if we meet Flow block first, thus skipping some blocks in the THEN region. Using "continue" will make the traversal going all the way to the return block of the function. |
llvm/lib/Target/AMDGPU/SIOptimizeVGPRLiveRange.cpp | ||
---|---|---|
386–387 | I take a second look, the order of the blocks does not matter here. We can use any order of traversal to collect all the blocks in the THEN region before this for-loop. We can use something like below to get all the blocks. (I choose SetVector mainly to keep the later iteration over the blocks is still in some kind of deterministic order. DenseSet also works.) SetVector<MachineBasicBlock*> Blocks; SmallVector<MachineBasicBlock *> WorkList; WorkList.push_back(If); while (!WorkList.empty()) { auto *MBB = WorkList.pop_back_val(); for (auto *Succ : MBB->successors()) { if (Succ != Flow && !Blocks.contains(Succ)) { WorkList.push_back(Succ); Blocks.insert(Succ); } } } |
LGTM with one minor comment.
llvm/lib/Target/AMDGPU/SIOptimizeVGPRLiveRange.cpp | ||
---|---|---|
377–384 | Could you also remove this piece of code for the ThenEntry? They are not needed anymore. |
Could you also remove this piece of code for the ThenEntry? They are not needed anymore.