brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 24a3f55 Raw
72 lines · plain
1; RUN: opt %loadNPMPolly -polly-invariant-load-hoisting -polly-detect-full-functions '-passes=polly-custom<scops>' -polly-print-scops -disable-output < %s | FileCheck %s2;3; This testcase checks for compatibility of the -detect-full-functions4; flag in combination with the -invariant-load-hoisting option. More5; specifically, ScopHelper.cpp::isHoistableLoad only gets called if6; -invariant-load-hoisting is enabled. This function, however, had a bug7; which caused a crash if the region argument was top-level. This test8; is a minimal example that hits this specific code path.9;10; Also note that this file's IR is in no way optimized, i.e. it was11; generated with clang -O0 from the following C-code:12;13;    void test() {14;      int A[] = {1, 2, 3, 4, 5};15;      int len = (sizeof A) / sizeof(int);16;      for (int i = 0; i < len; ++i) {17;        A[i] = A[i] * 2;18;      }19;    }20;21; This is also the reason why polly does not detect any scops (the loop22; variable i is loaded from and stored to memory in each iteration):23;24; CHECK:      region: 'for.cond => for.end' in function 'test':25; CHECK-NEXT: Invalid Scop!26; CHECK-NEXT: region: 'entry => <Function Return>' in function 'test':27; CHECK-NEXT: Invalid Scop!28;29target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"30 31@test.A = private unnamed_addr constant [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5], align 1632 33define void @test() {34entry:35  %A = alloca [5 x i32], align 1636  %len = alloca i32, align 437  %i = alloca i32, align 438  call void @llvm.memcpy.p0.p0.i64(ptr %A, ptr @test.A, i64 20, i32 16, i1 false)39  store i32 5, ptr %len, align 440  store i32 0, ptr %i, align 441  br label %for.cond42 43for.cond:                                         ; preds = %for.inc, %entry44  %0 = load i32, ptr %i, align 445  %1 = load i32, ptr %len, align 446  %cmp = icmp slt i32 %0, %147  br i1 %cmp, label %for.body, label %for.end48 49for.body:                                         ; preds = %for.cond50  %2 = load i32, ptr %i, align 451  %idxprom = sext i32 %2 to i6452  %arrayidx = getelementptr inbounds [5 x i32], ptr %A, i64 0, i64 %idxprom53  %3 = load i32, ptr %arrayidx, align 454  %mul = mul nsw i32 %3, 255  %4 = load i32, ptr %i, align 456  %idxprom1 = sext i32 %4 to i6457  %arrayidx2 = getelementptr inbounds [5 x i32], ptr %A, i64 0, i64 %idxprom158  store i32 %mul, ptr %arrayidx2, align 459  br label %for.inc60 61for.inc:                                          ; preds = %for.body62  %5 = load i32, ptr %i, align 463  %inc = add nsw i32 %5, 164  store i32 %inc, ptr %i, align 465  br label %for.cond66 67for.end:                                          ; preds = %for.cond68  ret void69}70 71declare void @llvm.memcpy.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i32, i1)72