This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Add missing pass dependencies for IRTranslator
ClosedPublic

Authored by qcolombet on Oct 8 2020, 12:12 PM.

Details

Summary

The IRTranslator depends on the branch probability info pass when the optimization level is different than None and it depends all the time on the StackProtector pass.

We have to explicitly call out pass dependencies otherwise the pass manager may not be able to schedule the IRTranslator.

Right now we are lucky because previous passes depend on the branch probability info pass (like the Global Variable Optimization) and the stack protector pass is initialized in initializeCodeGen.
However, if the target has a custom pipeline without any passes like Global Variable Optimization, the pipeline creation will fail, at least because of the branch probability info pass dependency (it is unlikely that initializeCodeGen is not called).

Note: We can alternatively fix this problem by calling initializeBranchProbabilityInfoWrapperPassPass inside the constructor of IRTranslator if we don't like the static dependency from the INITIALIZE_PASS_DEPENDENCY macro.
Note2: We have in theory the same problem for all the dependencies added by getSelectionDAGFallbackAnalysisUsage. Right now this is not a problem because that function does not actually pull any dependendency.

Diff Detail

Event Timeline

qcolombet created this revision.Oct 8 2020, 12:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 8 2020, 12:12 PM
qcolombet requested review of this revision.Oct 8 2020, 12:12 PM

LGTM assuming there's no reasonable test for this.

aemerson accepted this revision.Oct 8 2020, 1:40 PM
This revision is now accepted and ready to land.Oct 8 2020, 1:40 PM

Thanks for the quick review @aemerson!

LGTM assuming there's no reasonable test for this.

I guess we could build a custom pipeline in a unit test but it sounded overkill.