I'm wondering if the documentation for LoopPass (<a href="http://llvm.org/docs/WritingAnLLVMPass.html#LoopPass">http://llvm.org/docs/WritingAnLLVMPass.html#LoopPass</a>) is misleading or incorrect (or if I'm just missing something.) The documentation states:<div>
<br></div><div>"<span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium">The </span><tt style="color:rgb(0,0,0)">doFinalization</tt><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium"> method ... is called when the pass framework has finished calling </span><a href="http://llvm.org/docs/WritingAnLLVMPass.html#runOnLoop" style="font-family:'Times New Roman';font-size:medium"><tt>runOnLoop</tt></a><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium"> for every loop in the program being compiled."</span></div>
<div><br></div><div>From this, I understood that for a single instance of a LoopPass sub-class, the doFinalization method would be called exactly once, after all loops had been seen. However in practice I am seeing doFinalization() being called multiple times per program. Digging into the code, it appears that LPPassManager actually makes the calls to doFinalization() at the end of it's runOnFunction() method (<a href="http://llvm.org/docs/doxygen/html/LoopPass_8cpp_source.html#l00281">http://llvm.org/docs/doxygen/html/LoopPass_8cpp_source.html#l00281</a>, at time of writing). This therefore means that doFinalization() can be called multiple times per LoopPass; as many as there are functions defined in the input file.</div>
<div><br></div><div>Assuming I have made no mistakes here, is this a case of poorly written documentation, or an error in the implementation? I note that FPPassManager does it calls to FunctionPass' doFinalization() in it's own doFinalization() method, which seems the correct behaviour to me.</div>
<div><br></div><div>Thanks,<br>Stephen</div>