<div dir="ltr">We're sorting out the custom inliner in <a href="https://reviews.llvm.org/D94153">https://reviews.llvm.org/D94153</a>.<div><br></div><div>As for LegacyDivergenceAnalysis and Transforms/LoopUnswitch/AMDGPU/divergent-unswitch.ll, if there's no response, I'll just pin the test to the legacy PM, since it's testing an AMDGPU-specific optimization setting (disabling loop unswitching on divergent loop conditions). If there are noticeable performance regressions related to this due to the NPM switch, the AMDGPU community can temporarily use the legacy PM and then port the relevant analysis passes and fix up loop unswitching for AMDGPU.</div><div><br></div><div>Then we should be good to go for turning on the new PM for opt when it's specified on the CMake command line.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 4, 2021 at 2:16 PM Arthur Eubanks <<a href="mailto:aeubanks@google.com">aeubanks@google.com</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"><div dir="ltr">I've ported most of the IR passes and added them to AMDGPU's opt pipeline.<div>There are 2 issues remaining:</div><div>1) LegacyDivergenceAnalysis is used in LoopUnswitch to avoid unswitching loops with divergent condition Values. I'm not sure what the state of the LegacyDivergenceAnalysis vs DivergenceAnalysis is. (Also the new PM only has SimpleLoopUnswitch instead of LoopUnswitch).</div><div>Transforms/LoopUnswitch/AMDGPU/divergent-unswitch.ll.</div><div>2) The AMDGPU backend has its own <a href="https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/AMDGPUInline.cpp" target="_blank">inliner</a> (set <a href="https://github.com/llvm/llvm-project/blob/92be640bd7d4fbc8e032a0aa81381a0246efa0be/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp#L438" target="_blank">here</a>). Any ideas for how to do custom inliner cost modeling in the new PM pipelines? Allow targets to override an analysis pass that the inliner uses to get an InlineAdvisor?</div><div>CodeGen/AMDGPU/amdgpu-inline.ll<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Dec 4, 2020 at 4:44 PM Arthur Eubanks <<a href="mailto:aeubanks@google.com" target="_blank">aeubanks@google.com</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"><div dir="ltr">Some indicative failing tests are under the llvm/test/CodeGen/AMDGPU directory when opt's -enable-new-pm flag is set to true by default. They should also be repro'able by adding a corresponding NPM RUN line, e.g. "opt -S -O1 -mtriple=amdgcn-- ..." -> "opt -S -passes='default<O1>' -mtriple=amdgcn-- ...".<div><br></div><div>I see the following AMDGPU-specific failures:</div><div>  LLVM :: CodeGen/AMDGPU/amdgpu-inline.ll<br>  LLVM :: CodeGen/AMDGPU/infer-addrpace-pipeline.ll<br>  LLVM :: CodeGen/AMDGPU/internalize.ll<br>  LLVM :: CodeGen/AMDGPU/llvm.amdgcn.wavefrontsize.ll<br>  LLVM :: CodeGen/AMDGPU/opt-pipeline.ll<br>  LLVM :: CodeGen/AMDGPU/propagate-attributes-clone.ll<br>  LLVM :: CodeGen/AMDGPU/propagate-attributes-single-set.ll<br>  LLVM :: CodeGen/AMDGPU/simplify-libcalls.ll<br>  LLVM :: CodeGen/AMDGPU/sroa-before-unroll.ll<br></div><div>  LLVM :: Transforms/LoopUnswitch/AMDGPU/divergent-unswitch.ll<br></div><div><br></div><div>(Also I took a closer look, actually it looks like NVPTX also needs updating, but NVPTXTargetMachine only adds two passes)</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Dec 4, 2020 at 3:48 PM Arthur Eubanks <<a href="mailto:aeubanks@google.com" target="_blank">aeubanks@google.com</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"><div dir="ltr">Currently AMDGPU is the last target which injects passes into the pipeline but hasn't been updated to work with the new pass manager.<div><br></div><div>Recently there was added support for the NPM's equivalent of TargetMachine::adjustPassManager(). (<a href="https://bugs.llvm.org/show_bug.cgi?id=47244" target="_blank">Bug</a>, <a href="https://reviews.llvm.org/D88138" target="_blank">Phab</a>). <a href="https://github.com/llvm/llvm-project/blob/99f79cbf31cc6ccdfa1aed253a64c5e8012f4ef7/llvm/lib/Target/BPF/BPFTargetMachine.cpp#L126" target="_blank">BPF</a> and Hexagon have their NPM equivalents implemented already, but <a href="https://github.com/llvm/llvm-project/blob/99f79cbf31cc6ccdfa1aed253a64c5e8012f4ef7/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp#L420" target="_blank">AMDGPU has a lot of custom passes added by adjustPassManager</a> and hasn't been updated to work with the NPM.</div><div><br></div><div>Could the maintainers of AMDGPU port the necessary passes to the new pass manager add them to AMDGPUTargetMachine::registerPassBuilderCallbacks()? I'm happy to provide any guidance if necessary. <a href="https://reviews.llvm.org/D91990" target="_blank">Here's</a> an example of porting a pass and adding it to the pipeline.</div></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>