Dear guys,<br><br> I am having problems to obtain good information from the LoopInfo. I am always getting a trip count of 0, even though I am clearly passing a loop with a constant bound. I am using this pass below:<br>
<br>void testLoopInfo(const Function& F) const {<br> const LoopInfo *LI = &getAnalysis<LoopInfo>();<br> Function::const_iterator BB = F.begin(), E = F.end();<br> for (; BB != E; ++BB) {<br> const Loop* l = LI->getLoopFor(&*BB);<br>
if (l != NULL) {<br> l->dump();<br> errs() << "BB:\t" << BB->getNameStr() << "\n" ;<br> errs() << "Is simplifyed loop?\t" << l->isLoopSimplifyForm() << "\n" ;<br>
errs() << "Tripcount " << l->getSmallConstantTripCount() << "\n" ;<br> const PHINode* phi = l->getCanonicalInductionVariable();<br> errs() << "Induction variable: " << *phi << "\n"; <br>
}<br> }<br>}<br><br>When I feed it with this program:<br>int main(int argc, char** argv) {<br> int i = 0;<br> for (; i < 4; i++) {<br> int j = 0;<br> for (; j < 8; j++) {<br> printf("%c\n", argv[i][j]);<br>
}<br> }<br>}<br><br>It prints the following info, where all the trip counts are zero. What am I doing wrong?<br><br>Hello: main<br>Loop at depth 1 containing: %bb4<header><exiting>,%bb3<latch>,%bb2,%bb,%bb1<br>
Loop at depth 2 containing: %bb2<header><exiting>,%bb1<latch><br>BB: bb<br>Is simplifyed loop? 1<br>Tripcount 0<br>Induction variable: printing a <null> value<br><br>Loop at depth 2 containing: %bb2<header><exiting>,%bb1<latch><br>
BB: bb1<br>Is simplifyed loop? 1<br>Tripcount 0<br>Induction variable: printing a <null> value<br><br>Loop at depth 2 containing: %bb2<header><exiting>,%bb1<latch><br>BB: bb2<br>Is simplifyed loop? 1<br>
Tripcount 0<br>Induction variable: printing a <null> value<br><br>Loop at depth 1 containing: %bb4<header><exiting>,%bb3<latch>,%bb2,%bb,%bb1<br> Loop at depth 2 containing: %bb2<header><exiting>,%bb1<latch><br>
BB: bb3<br>Is simplifyed loop? 1<br>Tripcount 0<br>Induction variable: printing a <null> value<br><br>Loop at depth 1 containing: %bb4<header><exiting>,%bb3<latch>,%bb2,%bb,%bb1<br> Loop at depth 2 containing: %bb2<header><exiting>,%bb1<latch><br>
BB: bb4<br>Is simplifyed loop? 1<br>Tripcount 0<br>Induction variable: printing a <null> value<br><br>Regards,<br><br>Douglas<br>