This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Break critical edge from RTC to original loop.
ClosedPublic

Authored by efriedma on Oct 27 2016, 5:32 PM.

Details

Summary

This makes polly generate a CFG which is closer to what we want in LLVM IR, with a loop preheader for the original loop. This is just a cleanup, but it exposes some fragile assumptions.

I'm not completely happy with the changes related to expandCodeFor; RTCBB->getTerminator() is basically a random insertion point which happens to work due to the way we generate runtime checks. I'm not sure what the right answer looks like, though.

Diff Detail

Repository
rL LLVM

Event Timeline

efriedma updated this revision to Diff 76143.Oct 27 2016, 5:32 PM
efriedma retitled this revision from to [CodeGen] Break critical edge from RTC to original loop..
efriedma updated this object.
efriedma added reviewers: grosser, Meinersbur.
efriedma set the repository for this revision to rL LLVM.
efriedma added subscribers: llvm-commits, pollydev.
grosser accepted this revision.Nov 1 2016, 3:11 PM
grosser edited edge metadata.

Hi Eli,

this change looks good to me, besides some minor comments. Can you possibly test this change also with POLLY_ENABLE_GPGPU_CODEGEN=ON.

Best,
Tobias

PS: Can you possibly add the [Polly] tag to future phabricator reviews. This is mostly to help people on the mailing list, as phabricator does not add the project name in its review messages.

include/polly/CodeGen/BlockGenerators.h
85 ↗(On Diff #76143)

Please document StartBlock.

include/polly/CodeGen/IslExprBuilder.h
128 ↗(On Diff #76143)

Could you document StartBlock?

(I know not all parameters are documented. Besides this obviously not being good, this seems useful especially for the change at discussion)

include/polly/Support/ScopHelper.h
348 ↗(On Diff #76143)

Could you document RTCBB?

lib/CodeGen/Utils.cpp
218 ↗(On Diff #76143)

This looks good to me.

lib/Support/ScopHelper.cpp
232 ↗(On Diff #76143)

I like that this patch makes the insert position of new instructions explicit, as the old code was clearly very fragile.

This change exposes really an unnecessary strong connection between the insert location and the run-time block where we currently insert code to. I wonder if we not even want to just name this InsertBlock instead of RTCBB.

This revision is now accepted and ready to land.Nov 1 2016, 3:11 PM
efriedma added inline comments.Nov 2 2016, 11:38 AM
lib/Support/ScopHelper.cpp
232 ↗(On Diff #76143)

I'm currently not completely sure what the intent here actually is... the code in question is exercised by precisely one regression test, and there aren't any comments explaining the logic.

I think it makes sense to make the variable name reflect the actual value; if someone does come through and clean this up at some point, they can rename it to something appropriate, or make the function take an actual insertion point as a parameter.

efriedma updated this revision to Diff 76760.Nov 2 2016, 11:51 AM
efriedma edited edge metadata.

Address review comments. Now builds with POLLY_ENABLE_GPGPU_CODEGEN.

OK. We can leave this as RTCBB. I would like to see this cleaned up, but this does not need to hold back this patch. I might improve this and add documentation when I get to it. Feel to commit this as it is.

This revision was automatically updated to reflect the committed changes.