<div dir="ltr">This is run on a function pass, specifically runOnFunction which only gives you current function &F. <div><br></div><div>Where do you get current module &M from? Can you even run a lower switch pass using the legacy pass manager system?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 12, 2021 at 5:09 PM Zhang <<a href="mailto:admin@mayuyu.io">admin@mayuyu.io</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>Hi:</div><div>As the message suggests, you'll need a PM for it.</div><div>Something like the following would do:</div><div><br></div><div>```</div><div>legacy::FunctionPassManager FPM(&M);;</div><div>FPM.add(createLowerSwitchPass());</div><div>FPM.run(Func)</div><div>```</div><div><br></div><div><br></div><div>Zhang</div><div><u></u><div> </div><div> </div><div style="color:rgb(0,0,0)"><div style="font-size:12px;font-family:"Arial Narrow";padding:2px 0px">------------------ Original ------------------</div><div style="font-size:12px;background:rgb(239,239,239);padding:8px"><div id="gmail-m_1415853436334990645menu_sender"><b>From: </b> "llvm-dev"<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>;</div><div><b>Date: </b> Sat, Nov 13, 2021 02:54 AM</div><div><b>To: </b> "llvm-dev"<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>; </div><div></div><div><b>Subject: </b> [llvm-dev] how to add createLowerSwitchPass to PassManager object?</div></div><div> </div><div><div id="gmail-m_1415853436334990645tmpcontent_res"></div><div dir="ltr">My pass crashes on the callsite of runOnFunction() as it calls GetAnalysis to LazyValue internally.<br><br>FunctionPass* lower = createLowerSwitchPass();<br>lower->runOnFunction(F);<br><br>The crash log says: <i>Assertion failed: (Resolver && "Pass has not been inserted into a PassManager object!")</i><div><i><br></i></div><div>How do I get the PassManager object to add LowerSwitchPass? I can't happen to find the object anywhere. Can the legacy pass manager run lower passes in llvm14? Alternatively, is there another method I can use to create LowerSwitchPass with the new PassManager?</div></div>
</div></div><u></u></div></blockquote></div>