Zhang via llvm-dev
2021-Nov-13 01:09 UTC
[llvm-dev] how to add createLowerSwitchPass to PassManager object?
Hi: As the message suggests, you'll need a PM for it. Something like the following would do: ``` legacy::FunctionPassManager FPM(&M);; FPM.add(createLowerSwitchPass()); FPM.run(Func) ``` Zhang ------------------ Original ------------------ From: "llvm-dev"<llvm-dev at lists.llvm.org>; Date: Sat, Nov 13, 2021 02:54 AM To: "llvm-dev"<llvm-dev at lists.llvm.org>; Subject: [llvm-dev] how to add createLowerSwitchPass to PassManager object? My pass crashes on the callsite of runOnFunction() as it calls GetAnalysis to LazyValue internally. FunctionPass* lower = createLowerSwitchPass(); lower->runOnFunction(F); The crash log says: Assertion failed: (Resolver && "Pass has not been inserted into a PassManager object!") 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? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211113/5fe16863/attachment.html>
Taher via llvm-dev
2021-Nov-17 23:56 UTC
[llvm-dev] how to add createLowerSwitchPass to PassManager object?
This is run on a function pass, specifically runOnFunction which only gives you current function &F. Where do you get current module &M from? Can you even run a lower switch pass using the legacy pass manager system? On Fri, Nov 12, 2021 at 5:09 PM Zhang <admin at mayuyu.io> wrote:> Hi: > As the message suggests, you'll need a PM for it. > Something like the following would do: > > ``` > legacy::FunctionPassManager FPM(&M);; > FPM.add(createLowerSwitchPass()); > FPM.run(Func) > ``` > > > Zhang > > > ------------------ Original ------------------ > *From: * "llvm-dev"<llvm-dev at lists.llvm.org>; > *Date: * Sat, Nov 13, 2021 02:54 AM > *To: * "llvm-dev"<llvm-dev at lists.llvm.org>; > *Subject: * [llvm-dev] how to add createLowerSwitchPass to PassManager > object? > > My pass crashes on the callsite of runOnFunction() as it calls GetAnalysis > to LazyValue internally. > > FunctionPass* lower = createLowerSwitchPass(); > lower->runOnFunction(F); > > The crash log says: *Assertion failed: (Resolver && "Pass has not been > inserted into a PassManager object!")* > > 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? >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211117/dec789fa/attachment.html>