Redmond, Paul
2011-Sep-23 18:28 UTC
[LLVMdev] reusing FunctionPassManager with different Modules
Hi, Is it generally safe to cache a FunctionPassManager and reuse it on modules other than the one it was constructed with (assuming they have the same target triple)? paul -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110923/cd845b59/attachment.html>
Nick Lewycky
2011-Sep-24 16:21 UTC
[LLVMdev] reusing FunctionPassManager with different Modules
On 09/23/2011 11:28 AM, Redmond, Paul wrote:> Hi, > > Is it generally safe to cache a FunctionPassManager and reuse it on > modules other than the one it was constructed with (assuming they have > the same target triple)?No. FunctionPass has a pair of methods, doInitialization and doFinalization, which take Module& and are allowed to read or modify it outside runOnFunction. Nick
Redmond, Paul
2011-Sep-25 15:29 UTC
[LLVMdev] reusing FunctionPassManager with different Modules
Thanks. The reason I ask is because I'm looking at some code that does just that. A single FunctionPassManager is constructed with a dummy Module and createStandardFunctionPasses is called on it. The FunctionPassManager cached and run on Functions in other Modules. So far I haven't noticed any problems but I guess that is because the passes added by createStandardFunctionPasses don't touch the Module. paul -----Original Message----- From: Nick Lewycky [mailto:nicholas at mxc.ca] Sent: Saturday, September 24, 2011 12:21 PM To: Redmond, Paul Cc: llvmdev at cs.uiuc.edu Subject: Re: [LLVMdev] reusing FunctionPassManager with different Modules On 09/23/2011 11:28 AM, Redmond, Paul wrote:> Hi, > > Is it generally safe to cache a FunctionPassManager and reuse it on > modules other than the one it was constructed with (assuming they have > the same target triple)?No. FunctionPass has a pair of methods, doInitialization and doFinalization, which take Module& and are allowed to read or modify it outside runOnFunction. Nick