diff options
| -rw-r--r-- | polly/include/polly/ScopDetection.h | 7 | ||||
| -rw-r--r-- | polly/lib/Analysis/ScopDetection.cpp | 8 | ||||
| -rw-r--r-- | polly/lib/Analysis/TempScopInfo.cpp | 7 |
3 files changed, 13 insertions, 9 deletions
diff --git a/polly/include/polly/ScopDetection.h b/polly/include/polly/ScopDetection.h index 6b664b06026..770aaf406ac 100644 --- a/polly/include/polly/ScopDetection.h +++ b/polly/include/polly/ScopDetection.h @@ -52,6 +52,7 @@ #include "llvm/Analysis/AliasSetTracker.h" #include "llvm/Pass.h" #include <map> +#include <memory> #include <set> using namespace llvm; @@ -89,16 +90,16 @@ struct MemAcc { const Instruction *Insn; // A pointer to the shape description of the array. - ArrayShape *Shape; + std::shared_ptr<ArrayShape> Shape; // Subscripts computed by delinearization. SmallVector<const SCEV *, 4> DelinearizedSubscripts; - MemAcc(const Instruction *I, ArrayShape *S) + MemAcc(const Instruction *I, std::shared_ptr<ArrayShape> S) : Insn(I), Shape(S), DelinearizedSubscripts() {} }; -typedef std::map<const Instruction *, MemAcc *> MapInsnToMemAcc; +typedef std::map<const Instruction *, MemAcc> MapInsnToMemAcc; typedef std::pair<const Instruction *, const SCEV *> PairInstSCEV; typedef std::vector<PairInstSCEV> AFs; typedef std::map<const SCEVUnknown *, AFs> BaseToAFs; diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index 235059df671..b169e0b367d 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -471,7 +471,7 @@ bool ScopDetection::hasAffineMemoryAccesses(DetectionContext &Context) const { for (const SCEVUnknown *BasePointer : Context.NonAffineAccesses) { Value *BaseValue = BasePointer->getValue(); - ArrayShape *Shape = new ArrayShape(BasePointer); + auto Shape = std::shared_ptr<ArrayShape>(new ArrayShape(BasePointer)); bool BasePtrHasNonAffine = false; // First step: collect parametric terms in all array references. @@ -527,8 +527,10 @@ bool ScopDetection::hasAffineMemoryAccesses(DetectionContext &Context) const { const Instruction *Insn = Pair.first; const SCEVAddRecExpr *AF = dyn_cast<SCEVAddRecExpr>(Pair.second); bool IsNonAffine = false; - MemAcc *Acc = new MemAcc(Insn, Shape); - TempMemoryAccesses.insert({Insn, Acc}); + TempMemoryAccesses.emplace(std::piecewise_construct, + std::forward_as_tuple(Insn), + std::forward_as_tuple(Insn, Shape)); + MemAcc *Acc = &TempMemoryAccesses.find(Insn)->second; if (!AF) { if (isAffineExpr(&CurRegion, Pair.second, *SE, BaseValue)) diff --git a/polly/lib/Analysis/TempScopInfo.cpp b/polly/lib/Analysis/TempScopInfo.cpp index 21a2c48a0f3..18eff7eff25 100644 --- a/polly/lib/Analysis/TempScopInfo.cpp +++ b/polly/lib/Analysis/TempScopInfo.cpp @@ -237,10 +237,11 @@ TempScopInfo::buildIRAccess(Instruction *Inst, Loop *L, Region *R, assert(BasePointer && "Could not find base pointer"); AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer); - MemAcc *Acc = InsnToMemAcc[Inst]; - if (PollyDelinearize && Acc) + auto AccItr = InsnToMemAcc.find(Inst); + if (PollyDelinearize && AccItr != InsnToMemAcc.end()) return IRAccess(Type, BasePointer->getValue(), AccessFunction, Size, true, - Acc->DelinearizedSubscripts, Acc->Shape->DelinearizedSizes); + AccItr->second.DelinearizedSubscripts, + AccItr->second.Shape->DelinearizedSizes); // Check if the access depends on a loop contained in a non-affine subregion. bool isVariantInNonAffineLoop = false; |

