Changes in directory llvm/lib/Transforms/Scalar:
LoopUnroll.cpp updated: 1.36 -> 1.37 --- Log message: Guard against huge loop trip counts in an APInt safe way. --- Diffs of the changes: (+7 -2) LoopUnroll.cpp | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) Index: llvm/lib/Transforms/Scalar/LoopUnroll.cpp diff -u llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.36 llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.37 --- llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.36 Mon Feb 5 17:32:05 2007 +++ llvm/lib/Transforms/Scalar/LoopUnroll.cpp Fri Mar 2 17:31:34 2007 @@ -190,10 +190,15 @@ ConstantInt *TripCountC = dyn_cast_or_null<ConstantInt>(L->getTripCount()); if (!TripCountC) return Changed; // Must have constant trip count! - uint64_t TripCountFull = TripCountC->getZExtValue(); - if (TripCountFull != TripCountC->getZExtValue() || TripCountFull == 0) + // Guard against huge trip counts. This also guards against assertions in + // APInt from the use of getZExtValue, below. + if (TripCountC->getValue().getActiveBits() > 32) return Changed; // More than 2^32 iterations??? + uint64_t TripCountFull = TripCountC->getZExtValue(); + if (TripCountFull == 0) + return Changed; // Zero iteraitons? + unsigned LoopSize = ApproximateLoopSize(L); DOUT << "Loop Unroll: F[" << Header->getParent()->getName() << "] Loop %" << Header->getName() << " Loop Size = " _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits