In if-conversion, there is a utility function MergeBlocks() that is used to merge blocks. However, when new edges are built in this function the edge weight is either not provided or not updated properly, leading to a modified CFG with incorrect edge weights. This patch corrects this issue. More information is provided in the comments.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I'd like profile update to be isolated in its own helper function. Have some examples in the comments (like in the test case) -- the example should show cfg before and after. The parameters also need to be documented.
lib/CodeGen/IfConversion.cpp | ||
---|---|---|
1701 ↗ | (On Diff #33655) | Should it be zero? |
1736 ↗ | (On Diff #33655) | Do you have example of this case? |
It is difficult to isolate profile update here as the profile data is needed when adding successors.
I have added a CFG example to the comment in this function. Some variables are also documented.
lib/CodeGen/IfConversion.cpp | ||
---|---|---|
1701 ↗ | (On Diff #33655) | I made a mistake here: I should get To2FromWeight before the edge weight is set to zero. Need to switch this statement with the one above. |
1736 ↗ | (On Diff #33655) | Yes. The test case in test/CodeGen/ARM/ifcvt-iter-indbr.ll covers this case. |
Looks ok to me. The code is pretty hard to follow, but I don't have any great ideas for making it easier.
lib/CodeGen/IfConversion.cpp | ||
---|---|---|
1689 ↗ | (On Diff #33729) | I know this is old code, but while you're here, maybe change this to a SmallVector and rename to FromSuccs? |
test/CodeGen/ARM/ifcvt-iter-indbr.ll | ||
2 ↗ | (On Diff #33729) | Should 2<&1 be 2>&1? |
Thanks for the review! Yes, this part is not easy to understand but I also could not find a way to improve the overall readability.
lib/CodeGen/IfConversion.cpp | ||
---|---|---|
1689 ↗ | (On Diff #33729) | Done. I found many uses of std::vector in this file. Do we need to change all of them to SmallVector? |
test/CodeGen/ARM/ifcvt-iter-indbr.ll | ||
2 ↗ | (On Diff #33729) | Right.. corrected. |
lib/CodeGen/IfConversion.cpp | ||
---|---|---|
1689 ↗ | (On Diff #33729) | You could look at them in a separate patch if you like, but it's probably not very important. I figured this one would be nice to fix when you're editing the function already. |