Revert "[polly] [ScopInfo] Don't pre-compute the name of the Scop's region."
authorPhilip Pfaffe <philip.pfaffe@gmail.com>
Wed, 2 May 2018 14:55:39 +0000 (14:55 +0000)
committerPhilip Pfaffe <philip.pfaffe@gmail.com>
Wed, 2 May 2018 14:55:39 +0000 (14:55 +0000)
This reverts commit 0f9dc03765dc301fff7a52e2a0e1dd3e5f3130c5, r328666.

The change introduced a use-after-free, caused by the temporary name string
being destroyed after converting it to a StringRef.

llvm-svn: 331363

polly/include/polly/ScopInfo.h
polly/lib/Analysis/ScopInfo.cpp

index 09bdefa..324cc27 100644 (file)
@@ -1716,6 +1716,9 @@ private:
   /// The underlying Region.
   Region &R;
 
+  /// The name of the SCoP (identical to the regions name)
+  std::string name;
+
   /// The ID to be assigned to the next Scop in a function
   static int NextScopID;
 
@@ -2452,7 +2455,7 @@ public:
   /// could be executed.
   bool isEmpty() const { return Stmts.empty(); }
 
-  const StringRef getName() const { return R.getNameStr(); }
+  const StringRef getName() const { return name; }
 
   using array_iterator = ArrayInfoSetTy::iterator;
   using const_array_iterator = ArrayInfoSetTy::const_iterator;
index 74e2314..e7c9240 100644 (file)
@@ -3329,8 +3329,8 @@ Scop::Scop(Region &R, ScalarEvolution &ScalarEvolution, LoopInfo &LI,
            DominatorTree &DT, ScopDetection::DetectionContext &DC,
            OptimizationRemarkEmitter &ORE)
     : IslCtx(isl_ctx_alloc(), isl_ctx_free), SE(&ScalarEvolution), DT(&DT),
-      R(R), HasSingleExitEdge(R.getExitingBlock()), DC(DC), ORE(ORE),
-      Affinator(this, LI),
+      R(R), name(R.getNameStr()), HasSingleExitEdge(R.getExitingBlock()),
+      DC(DC), ORE(ORE), Affinator(this, LI),
       ID(getNextID((*R.getEntry()->getParent()).getName().str())) {
   if (IslOnErrorAbort)
     isl_options_set_on_error(getIslCtx().get(), ISL_ON_ERROR_ABORT);