ScopDetection: Make sure we do not accidentally divide by zero
authorTobias Grosser <tobias@grosser.es>
Thu, 8 Sep 2016 14:08:05 +0000 (14:08 +0000)
committerTobias Grosser <tobias@grosser.es>
Thu, 8 Sep 2016 14:08:05 +0000 (14:08 +0000)
This code path is likely never triggered, but by still handling this case
locally we avoid warnings in clangs static analyzer.

llvm-svn: 280939

polly/lib/Analysis/ScopDetection.cpp

index 586beaf..b891c02 100644 (file)
@@ -1307,6 +1307,9 @@ bool ScopDetection::hasSufficientCompute(DetectionContext &Context,
                                          int NumLoops) const {
   int InstCount = 0;
 
+  if (NumLoops == 0)
+    return false;
+
   for (auto *BB : Context.CurRegion.blocks())
     if (Context.CurRegion.contains(LI->getLoopFor(BB)))
       InstCount += BB->size();