Hi all, I tried to have a LoopInfo object in a function pass, add addRequired<LoopInfo> in getAnalysisUsage, and then use getAnalysis<LoopInfo> in runOnFunction(). It worked OK. Now I want to have a module pass to traverse the functions, and similarly I want to have to loop information of the functions. When I did the above in runOnModule, and run the pass, the following error popped out: AnalysisType& llvm::Pass::getAnalysis() const [with AnalysisType = llvm::DominatorTree]: Assertion `Resolver && "Pass has not been inserted into a PassManager object!"' failed. Can anyone tell me the correct way to handle this in a module pass? Thanks a lot! Best, --Wenbin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110303/03ca1631/attachment.html>
On 3/3/11 3:09 PM, Wenbin Zhang wrote:> Hi all, > I tried to have a LoopInfo object in a function pass, add > addRequired<LoopInfo> in getAnalysisUsage, and then use > getAnalysis<LoopInfo> in runOnFunction(). It worked OK. > Now I want to have a module pass to traverse the functions, and > similarly I want to have to loop information of the functions. When I > did the above in runOnModule, and run the pass, the following error > popped out: > /AnalysisType& llvm::Pass::getAnalysis() const [with AnalysisType > llvm::DominatorTree]: Assertion `Resolver && "Pass has not been > inserted into a PassManager object!"' failed./ > // > Can anyone tell me the correct way to handle this in a module pass? > Thanks a lot!LoopInfo is a FunctionPass, so you have to use getAnalysis<LoopInfo>(F) where F is a pointer to the function that you want analyzed. Note that LoopInfo, in this instance, will be re-run every time you call getAnalysis on it (this is a result of using a FunctionPass within a ModulePass). Be sure to structure you code to only call getAnalysis<LoopInfo>(F) on each function just once, if possible. Also be sure that F is not a function declaration (i.e., a function with no body). -- John T.> Best, > --Wenbin-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110303/00370104/attachment.html>
Thanks John, I modify my code to like this:
bool XXX::ModulePass(Module &M){
....
LoopInfo &li = getAnalysis<LoopInfo>(fi);
....
}
Here fi is a Function* pointing to main().
Now when I run the pass, another error shows up:
AnalysisType& llvm::Pass::getAnalysisID(const llvm::PassInfo*,
llvm::Function&) [with AnalysisType = llvm::LoopInfo]: Assertion `ResultPass
&& "Unable to find requested analysis info"' failed.
Did I miss something? Thanks!
Best,
--Wenbin
----- Original Message -----
From: John Criswell
To: Wenbin Zhang
Cc: llvmdev at cs.uiuc.edu
Sent: Thursday, March 03, 2011 4:26 PM
Subject: Re: [LLVMdev] how can I have LoopInfo in a module pass?
On 3/3/11 3:09 PM, Wenbin Zhang wrote:
Hi all,
I tried to have a LoopInfo object in a function pass, add
addRequired<LoopInfo> in getAnalysisUsage, and then use
getAnalysis<LoopInfo> in runOnFunction(). It worked OK.
Now I want to have a module pass to traverse the functions, and similarly I
want to have to loop information of the functions. When I did the above in
runOnModule, and run the pass, the following error popped out:
AnalysisType& llvm::Pass::getAnalysis() const [with AnalysisType =
llvm::DominatorTree]: Assertion `Resolver && "Pass has not been
inserted into a PassManager object!"' failed.
Can anyone tell me the correct way to handle this in a module pass? Thanks a
lot!
LoopInfo is a FunctionPass, so you have to use getAnalysis<LoopInfo>(F)
where F is a pointer to the function that you want analyzed.
Note that LoopInfo, in this instance, will be re-run every time you call
getAnalysis on it (this is a result of using a FunctionPass within a
ModulePass). Be sure to structure you code to only call
getAnalysis<LoopInfo>(F) on each function just once, if possible.
Also be sure that F is not a function declaration (i.e., a function with no
body).
-- John T.
Best,
--Wenbin
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20110303/7ffb73cb/attachment.html>