There are places in MachineBlockPlacement where a worklist is filled in pretty much identical way. The code is duplicated. This refactor it so that the same code is used in both scenarii.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/CodeGen/MachineBlockPlacement.cpp | ||
---|---|---|
591 ↗ | (On Diff #50395) | Should this be a continue? |
593 ↗ | (On Diff #50395) | Same as above. continue? |
598 ↗ | (On Diff #50395) | If you don't mind, I'd prefer to stick with the style of the original code. if (Chain.UnscheduledPredecessors == 0) BlockWorkList.push_back(*Chain.begin()); |
lib/CodeGen/MachineBlockPlacement.cpp | ||
---|---|---|
598 ↗ | (On Diff #50462) | Honestly, I don't follow your argument. I prefer this style (i.e., the original code): if (Chain.UnscheduledPredecessors == 0) BlockWorkList.push_back(*Chain.begin()); rather than your change (below): if (Chain.UnscheduledPredecessors != 0) return; BlockWorkList.push_back(*Chain.begin()); For this patch can we just stick with the original code? |
lib/CodeGen/MachineBlockPlacement.cpp | ||
---|---|---|
593 ↗ | (On Diff #50462) | Do you have a suggestion on how to build such test case ? |
598 ↗ | (On Diff #50462) | It can. I just would have to change this in D17625 instead of here, which really I don't care. I was asked to extract NFC changes in this patch, so that made sense to include this. |
lib/CodeGen/MachineBlockPlacement.cpp | ||
---|---|---|
598 ↗ | (On Diff #50462) | I agree with Chad here -- unless it helps reducing if nesting level, early return here does not help readability -- the original code seems more readable: if (Chain.UnscheduledPredecessors == 0) { // update worklist(s) } |
lib/CodeGen/MachineBlockPlacement.cpp | ||
---|---|---|
277 ↗ | (On Diff #50515) | Though not done for existing methods, I think it is better to add a slightly detailed comments for this method. Otherwise the refactoring looks good. |