[ScopInfo] Allow epilogues to be the main statement of a BB.

Do not add a "_last" suffix to the statement name if there is no (other)
main statement for a basic block. In other words, it becomes the main
statement itself. This further reduces the statement naming difference
between -polly-stmt-granularity=bb and
-polly-stmt-granularity=scalar-indep.

git-svn-id: https://llvm.org/svn/llvm-project/polly/trunk@324168 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/ScopBuilder.cpp b/lib/Analysis/ScopBuilder.cpp
index 794e6d8..ebb97d9 100644
--- a/lib/Analysis/ScopBuilder.cpp
+++ b/lib/Analysis/ScopBuilder.cpp
@@ -856,6 +856,7 @@
   // Finally build the statements.
   int Count = 0;
   long BBIdx = scop->getNextStmtIdx();
+  bool MainFound = false;
   for (auto &Instructions : reverse(LeaderToInstList)) {
     std::vector<Instruction *> &InstList = Instructions.second;
 
@@ -866,6 +867,8 @@
                InstList.end();
     else
       IsMain = (Count == 0);
+    if (IsMain)
+      MainFound = true;
 
     std::reverse(InstList.begin(), InstList.end());
     std::string Name = makeStmtName(BB, BBIdx, Count, IsMain);
@@ -877,7 +880,7 @@
   // instructions, but holds the PHI write accesses for successor basic blocks,
   // if the incoming value is not defined in another statement if the same BB.
   // The epilogue will be removed if no PHIWrite is added to it.
-  std::string EpilogueName = makeStmtName(BB, BBIdx, Count, false, true);
+  std::string EpilogueName = makeStmtName(BB, BBIdx, Count, !MainFound, true);
   scop->addScopStmt(BB, EpilogueName, L, {});
 }