<div dir="ltr"><div dir="ltr">On Fri, Jun 14, 2019 at 10:56 PM Leonard Chan <<a href="mailto:leonardchan@google.com">leonardchan@google.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks for bringing this up. I'm not sure how polly works, but <i>I think</i> I found out the root of the problem.<div><br></div><div>For new pass manager runs, the FunctionAnalysisManagerModuleProxy is registered in PassBuilder::crossRegisterProxies(). `opt` calls this in `llvm::runPassPipeline()` but only if the new PM driver is used (which can be triggered by passing `-passes='...'`). The command in question though does not seem to be using the new PM, so the problem is that this new PM pass is being used in a legacy PM run.</div><div><br></div><div>After some digging, it seems that the new PM AlwaysInlinerPass (and some other new PM passes) are created and run in `polly/trunk/lib/Transform/ScopInliner.cpp` as a part of ScopInliner::runOnSCC(), which should be a legacy pass.</div><div><br></div><div>I'd double check this with Chandler or Philip, but I imagine the correct thing to do is to instead change some of the body of ScopInliner::runOnSCC() to 1) use the legacy PM classes (like AlwaysInlinerLegacyPass), and 2) change ScopInliner to have the AlwaysInliner as a pass dependency instead of invoking it directly in the run.</div></div></blockquote><div><br></div><div>Or 3) register and set up the analysis manager inside of the ScopInliner.</div><div><br></div><div>Nothing goes wrong by nesting new PM inside of something else. You just have to build and set up the analysis manager correctly to hand to the underlying pass.</div><div><br></div><div>FWIW, I agree w/ your analysis of the problem and the available solutions. I don't have a strong opinion. It'd be good to land one of these ore temporarily revert until we figure out what to do.... #3 is honestly probably the minimal change -- it should allow things to work exactly as they did before.</div><div>  </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>- Leonard</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 14, 2019 at 9:20 PM Michael Kruse <<a href="mailto:llvm-commits@meinersbur.de" target="_blank">llvm-commits@meinersbur.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This made two regression tests in Polly crash:<br>
<br>
Debug\bin\opt.exe  -polly-process-unprofitable  -polly-remarks-minimal<br>
 -polly-use-llvm-names<br>
-polly-import-jscop-dir=C:\Users\meinersbur\src\llvm\tools\polly\test\ScopInliner<br>
 -polly-codegen-verify  -polly-detect-full-functions<br>
-polly-scop-inliner  -polly-scops -analyze<br>
-polly-invariant-load-hoisting<br>
Assertion failed: AnalysisPasses.count(PassT::ID()) && "This analysis<br>
pass was not registered prior to being queried", file<br>
C:\Users\meinersbur\src\llvm\include\llvm/IR/PassManager.h, line 778<br>
<br>
with PassT being FunctionAnalysisManagerModuleProxy. Where is this<br>
pass supposed to be registered?<br>
<br>
Michael<br>
<br>
<br>
Am Do., 13. Juni 2019 um 13:15 Uhr schrieb Leonard Chan via<br>
llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>>:<br>
><br>
> Author: leonardchan<br>
> Date: Thu Jun 13 11:18:40 2019<br>
> New Revision: 363287<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=363287&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=363287&view=rev</a><br>
> Log:<br>
> [clang][NewPM] Fix broken -O0 test from missing assumptions<br>
><br>
> Add an AssumptionCache callback to the InlineFuntionInfo used for the<br>
> AlwaysInlinerPass to match codegen of the AlwaysInlinerLegacyPass to generate<br>
> llvm.assume. This fixes CodeGen/builtin-movdir.c when new PM is enabled by<br>
> default.<br>
><br>
> Differential Revision: <a href="https://reviews.llvm.org/D63170" rel="noreferrer" target="_blank">https://reviews.llvm.org/D63170</a><br>
><br>
> Modified:<br>
>     llvm/trunk/lib/Transforms/IPO/AlwaysInliner.cpp<br>
><br>
> Modified: llvm/trunk/lib/Transforms/IPO/AlwaysInliner.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/AlwaysInliner.cpp?rev=363287&r1=363286&r2=363287&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/AlwaysInliner.cpp?rev=363287&r1=363286&r2=363287&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Transforms/IPO/AlwaysInliner.cpp (original)<br>
> +++ llvm/trunk/lib/Transforms/IPO/AlwaysInliner.cpp Thu Jun 13 11:18:40 2019<br>
> @@ -31,8 +31,17 @@ using namespace llvm;<br>
><br>
>  #define DEBUG_TYPE "inline"<br>
><br>
> -PreservedAnalyses AlwaysInlinerPass::run(Module &M, ModuleAnalysisManager &) {<br>
> -  InlineFunctionInfo IFI;<br>
> +PreservedAnalyses AlwaysInlinerPass::run(Module &M,<br>
> +                                         ModuleAnalysisManager &MAM) {<br>
> +  // Add inline assumptions during code generation.<br>
> +  FunctionAnalysisManager &FAM =<br>
> +      MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();<br>
> +  std::function<AssumptionCache &(Function &)> GetAssumptionCache =<br>
> +      [&](Function &F) -> AssumptionCache & {<br>
> +    return FAM.getResult<AssumptionAnalysis>(F);<br>
> +  };<br>
> +  InlineFunctionInfo IFI(/*cg=*/nullptr, &GetAssumptionCache);<br>
> +<br>
>    SmallSetVector<CallSite, 16> Calls;<br>
>    bool Changed = false;<br>
>    SmallVector<Function *, 16> InlinedFunctions;<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>
</blockquote></div></div>