This is an archive of the discontinued LLVM Phabricator instance.

[Polly] IR cleanup after CodeGeneration
ClosedPublic

Authored by Meinersbur on Nov 4 2015, 8:07 AM.

Details

Summary

Re-run canonicalization passes after Polly's code generation.

The set of passes currently added here are nearly all the passes between --polly-position=early and --polly-position=before-vectorizer, i.e. all passes that would usually run after Polly.

In order to run these only if Polly actually modified the code, we add a function attribute "polly-optimzed" to a function that contains generated code. The cleanup pass is skipped if the function does have this attribute.

There is no support by the (legacy) PassManager to run passes only under some conditions. One could have wrapped all transformation passes to run only when CodeGeneration changed the code, but the analyses would run anyway. This patch creates an independent pass manager. The disadvantages are that all analyses have to re-run even if preserved and it does not honor compiler switches like the PassManagerBuilder does.

Diff Detail

Event Timeline

Meinersbur updated this revision to Diff 39206.Nov 4 2015, 8:07 AM
Meinersbur retitled this revision from to [Polly] Cleanup IR after CodeGeneration (WIP).
Meinersbur updated this object.
Meinersbur added reviewers: jdoerfert, grosser.
Meinersbur added a project: Restricted Project.
Meinersbur added subscribers: llvm-commits, pollydev.
Meinersbur added inline comments.Nov 4 2015, 8:12 AM
test/ScopInfo/new-domain-construction-schedule-not-freed.ll
6 ↗(On Diff #39206)

The scop is sometimes removed completely because it has no side effects. This should not be specific to this patch, but occurred occasionally when testing it.

grosser edited edge metadata.Nov 23 2015, 10:26 PM

Hi Michael,

sorry for the delay. This patch is clearly needed. The approach looks generally fine, but I am slightly concerned about the introduction of a RememberCodegenPass, as pass manager "abuses" are often fragile and I am not 100% convinced this will work with the new pass manager. Instead of trying to figure out if/how to make this work, I would propose to just pass the "is-modified" information as function level metadata or a named function attribute.

Best,
Tobias

test/ScopInfo/new-domain-construction-schedule-not-freed.ll
6 ↗(On Diff #39206)

I am confused. Why does a change in the pass manager pipeline affect this test case. The pass manager is not even involved here, no?

Meinersbur updated this revision to Diff 41200.Nov 25 2015, 4:58 PM
Meinersbur retitled this revision from [Polly] Cleanup IR after CodeGeneration (WIP) to [Polly] IR cleanup after CodeGeneration.
Meinersbur updated this object.
Meinersbur edited edge metadata.

Instead of a RememberCodegen pass, use a "polly-optimized" function attribute.

Meinersbur updated this revision to Diff 41201.Nov 25 2015, 5:01 PM

Remove bogus pass dependency

Hi Michael,

this LGFM.

Tobias

This revision was automatically updated to reflect the committed changes.