NewPM support for CodeGenPrepare


CodeGenPrepare is currently a function pass which depends on ProfileSummaryInfoWrapperPass, which is an ImmutablePass, to obtain ProfileSummaryInfo. While this works seamlessly with the legacy pass manager, ProfileSummaryInfo can only be obtained from ProfileSummaryAnalysis which is a module analysis pass for the new pass manager case. Since I only have access to FunctionAnalysisManager, I am not sure how to collect ProfileSummaryInfo. Any ideas?

Anshil Gandhi

You need to fetch it from the MAM proxy, using something like this:

auto &MAMProxy = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
auto *PSI = MAMProxy.getCachedResult<ProfileSummaryAnalysis>(M);

Note that PSI must be precomputed at that point, it cannot be lazily computed. In tests this is done with an explicit require<profile-summary>, in the pipeline using RequireAnalysisPass<ProfileSummaryAnalysis, Module>().

1 Like