Index: include/polly/ScopDetectionDiagnostic.h =================================================================== --- include/polly/ScopDetectionDiagnostic.h +++ include/polly/ScopDetectionDiagnostic.h @@ -91,7 +91,6 @@ // Other rrkOther, rrkIntToPtr, - rrkAlloca, rrkUnknownInst, rrkEntry, rrkUnprofitable, @@ -678,27 +677,6 @@ }; //===----------------------------------------------------------------------===// -/// @brief Captures errors with alloca instructions. -class ReportAlloca : public ReportOther { - //===--------------------------------------------------------------------===// - Instruction *Inst; - -public: - ReportAlloca(Instruction *Inst); - - /// @name LLVM-RTTI interface - //@{ - static bool classof(const RejectReason *RR); - //@} - - /// @name RejectReason interface - //@{ - virtual std::string getMessage() const override; - virtual const DebugLoc &getDebugLoc() const override; - //@} -}; - -//===----------------------------------------------------------------------===// /// @brief Captures errors with unknown instructions. class ReportUnknownInst : public ReportOther { //===--------------------------------------------------------------------===// Index: lib/Analysis/ScopDetection.cpp =================================================================== --- lib/Analysis/ScopDetection.cpp +++ lib/Analysis/ScopDetection.cpp @@ -732,12 +732,8 @@ return invalid(Context, /*Assert=*/true, &Inst); } - if (!Inst.mayWriteToMemory() && !Inst.mayReadFromMemory()) { - if (!isa(Inst)) - return true; - - return invalid(Context, /*Assert=*/true, &Inst); - } + if (!Inst.mayWriteToMemory() && !Inst.mayReadFromMemory()) + return true; // Check the access function. if (isa(Inst) || isa(Inst)) { Index: lib/Analysis/ScopDetectionDiagnostic.cpp =================================================================== --- lib/Analysis/ScopDetectionDiagnostic.cpp +++ lib/Analysis/ScopDetectionDiagnostic.cpp @@ -452,24 +452,6 @@ } //===----------------------------------------------------------------------===// -// ReportAlloca. - -ReportAlloca::ReportAlloca(Instruction *Inst) - : ReportOther(rrkAlloca), Inst(Inst) {} - -std::string ReportAlloca::getMessage() const { - return "Alloca instruction: " + *Inst; -} - -const DebugLoc &ReportAlloca::getDebugLoc() const { - return Inst->getDebugLoc(); -} - -bool ReportAlloca::classof(const RejectReason *RR) { - return RR->getKind() == rrkAlloca; -} - -//===----------------------------------------------------------------------===// // ReportUnknownInst. ReportUnknownInst::ReportUnknownInst(Instruction *Inst) Index: test/Isl/CodeGen/alloca-in-region.ll =================================================================== --- /dev/null +++ test/Isl/CodeGen/alloca-in-region.ll @@ -0,0 +1,106 @@ +; RUN: opt %loadPolly -polly-codegen -mem2reg -S < %s | FileCheck %s +; +; void f(int *A) { +; for (int i = 0; i < 10; i++) { +; int B[10]; +; for (int j = 0; j < 10; j++) +; B[j] = 0; +; for (int j = 0; j < i; j++) +; B[j] += A[i]; +; for (int j = 0; j < i; j++) +; A[i] += B[j]; +; } +; } +; +; +; CHECK: polly.stmt.for.body: +; CHECK-NEXT: %p_B = alloca [10 x i32], align 16 +; +; CHECK: polly.stmt.for.body.3: +; CHECK-NEXT: %p_arrayidx = getelementptr inbounds [10 x i32], [10 x i32]* %p_B, i64 0, i64 %polly.indvar4 +; +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" + +define void @f(i32* %A) { +entry: + br label %for.cond + +for.cond: ; preds = %for.inc.27, %entry + %indvars.iv12 = phi i64 [ %indvars.iv.next13, %for.inc.27 ], [ 0, %entry ] + %indvars.iv8 = phi i32 [ %indvars.iv.next9, %for.inc.27 ], [ 0, %entry ] + %exitcond14 = icmp ne i64 %indvars.iv12, 10 + br i1 %exitcond14, label %for.body, label %for.end.29 + +for.body: ; preds = %for.cond + %B = alloca [10 x i32], align 16 + br label %for.cond.1 + +for.cond.1: ; preds = %for.inc, %for.body + %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %for.body ] + %exitcond = icmp ne i64 %indvars.iv, 10 + br i1 %exitcond, label %for.body.3, label %for.end + +for.body.3: ; preds = %for.cond.1 + %arrayidx = getelementptr inbounds [10 x i32], [10 x i32]* %B, i64 0, i64 %indvars.iv + store i32 0, i32* %arrayidx, align 4 + br label %for.inc + +for.inc: ; preds = %for.body.3 + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 + br label %for.cond.1 + +for.end: ; preds = %for.cond.1 + br label %for.cond.5 + +for.cond.5: ; preds = %for.inc.12, %for.end + %indvars.iv1 = phi i64 [ %indvars.iv.next2, %for.inc.12 ], [ 0, %for.end ] + %lftr.wideiv = trunc i64 %indvars.iv1 to i32 + %exitcond5 = icmp ne i32 %lftr.wideiv, %indvars.iv8 + br i1 %exitcond5, label %for.body.7, label %for.end.14 + +for.body.7: ; preds = %for.cond.5 + %arrayidx9 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv12 + %tmp = load i32, i32* %arrayidx9, align 4 + %arrayidx11 = getelementptr inbounds [10 x i32], [10 x i32]* %B, i64 0, i64 %indvars.iv1 + %tmp15 = load i32, i32* %arrayidx11, align 4 + %add = add nsw i32 %tmp15, %tmp + store i32 %add, i32* %arrayidx11, align 4 + br label %for.inc.12 + +for.inc.12: ; preds = %for.body.7 + %indvars.iv.next2 = add nuw nsw i64 %indvars.iv1, 1 + br label %for.cond.5 + +for.end.14: ; preds = %for.cond.5 + br label %for.cond.16 + +for.cond.16: ; preds = %for.inc.24, %for.end.14 + %indvars.iv6 = phi i64 [ %indvars.iv.next7, %for.inc.24 ], [ 0, %for.end.14 ] + %lftr.wideiv10 = trunc i64 %indvars.iv6 to i32 + %exitcond11 = icmp ne i32 %lftr.wideiv10, %indvars.iv8 + br i1 %exitcond11, label %for.body.18, label %for.end.26 + +for.body.18: ; preds = %for.cond.16 + %arrayidx20 = getelementptr inbounds [10 x i32], [10 x i32]* %B, i64 0, i64 %indvars.iv6 + %tmp16 = load i32, i32* %arrayidx20, align 4 + %arrayidx22 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv12 + %tmp17 = load i32, i32* %arrayidx22, align 4 + %add23 = add nsw i32 %tmp17, %tmp16 + store i32 %add23, i32* %arrayidx22, align 4 + br label %for.inc.24 + +for.inc.24: ; preds = %for.body.18 + %indvars.iv.next7 = add nuw nsw i64 %indvars.iv6, 1 + br label %for.cond.16 + +for.end.26: ; preds = %for.cond.16 + br label %for.inc.27 + +for.inc.27: ; preds = %for.end.26 + %indvars.iv.next13 = add nuw nsw i64 %indvars.iv12, 1 + %indvars.iv.next9 = add nuw nsw i32 %indvars.iv8, 1 + br label %for.cond + +for.end.29: ; preds = %for.cond + ret void +}