This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyCFG] Reduce memory churn during common case for branch commoning [NFC]
AbandonedPublic

Authored by reames on Aug 29 2018, 5:32 PM.

Details

Summary

I figured this one was worthy of an extra set of eyes despite being reasonable straight forward code wise. While the patch does exactly what the subject says, the motivation is really to simplify a follow on patch (https://reviews.llvm.org/D51458). I'm legitimately unsure if it makes sense to land this in isolation, or just role it into the combined patch.

Diff Detail

Event Timeline

reames created this revision.Aug 29 2018, 5:32 PM
reames updated this revision to Diff 163237.Aug 29 2018, 5:39 PM

(slightly modified patch to reduce overhead for multiple predecessor case too)

reames updated this revision to Diff 163239.Aug 29 2018, 5:45 PM

reverse last rebase, the small addition was buggy (iterator invalidation)

mkazantsev requested changes to this revision.Aug 30 2018, 12:39 AM
mkazantsev added inline comments.
lib/Transforms/Utils/SimplifyCFG.cpp
2694

What if the predecessor block has more than one successor? You'll end up moving loads and other dangerous instruction across conditional branches.

This revision now requires changes to proceed.Aug 30 2018, 12:39 AM
mkazantsev accepted this revision.Aug 30 2018, 12:58 AM

Oh, I've misread what function that was. If both branches go to the same block then it should be fine.

lib/Transforms/Utils/SimplifyCFG.cpp
2694

I've misread what method was that, my bad. :) This should be fine.
However I have no idea how iterators interact with moveBefore, it may be safier to use an auxiliary vector here for that.

This revision is now accepted and ready to land.Aug 30 2018, 12:58 AM
reames abandoned this revision.Mar 15 2019, 12:55 PM

Not something I expect to get back to.