brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 28ee6c6 Raw
81 lines · plain
1; RUN: opt -aa-pipeline=basic-aa -passes='print<access-info>' -disable-output  < %s 2>&1 | FileCheck %s2 3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"4 5; We shouldn't quit the analysis if we encounter a pointer without known6; bounds *unless* we actually need to emit a memcheck for it.  (We only7; compute bounds for SCEVAddRecs so A[i*i] is deemed not having known bounds.)8;9; for (i = 0; i < 20; ++i)10;   A[i*i] *= 2;11 12; CHECK-LABEL: addrec_squared13; CHECK-NEXT: for.body:14; CHECK-NEXT:   Report: unsafe dependent memory operations in loop15; CHECK-NOT:    Report: cannot identify array bounds16; CHECK-NEXT:   Unsafe indirect dependence.17; CHECK-NEXT:     Dependences:18; CHECK-NEXT:       IndirectUnsafe:19; CHECK-NEXT:         %loadA = load i16, ptr %arrayidxA, align 2 ->20; CHECK-NEXT:         store i16 %mul, ptr %arrayidxA, align 221 22define void @addrec_squared(ptr %a) {23entry:24  br label %for.body25 26for.body:                                         ; preds = %for.body, %entry27  %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]28 29  %access_ind = mul i64 %ind, %ind30 31  %arrayidxA = getelementptr inbounds i16, ptr %a, i64 %access_ind32  %loadA = load i16, ptr %arrayidxA, align 233 34  %mul = mul i16 %loadA, 235 36  store i16 %mul, ptr %arrayidxA, align 237 38  %add = add nuw nsw i64 %ind, 139  %exitcond = icmp eq i64 %add, 2040  br i1 %exitcond, label %for.end, label %for.body41 42for.end:                                          ; preds = %for.body43  ret void44}45 46; TODO: We cannot compute the bound for %arrayidxA_ub, because the index is47; loaded on each iteration. As %a and %b are no-alias, no memchecks are required48; and unknown bounds should not prevent further analysis.49define void @loaded_bound(ptr noalias %a, ptr noalias %b) {50; CHECK-LABEL: loaded_bound51; CHECK-NEXT:  for.body:52; CHECK-NEXT:    Report: cannot identify array bounds53; CHECK-NEXT:    Dependences:54; CHECK-NEXT:    Run-time memory checks:55 56entry:57  br label %for.body58 59for.body:                                         ; preds = %for.body, %entry60  %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]61 62  %iv.next = add nuw nsw i64 %iv, 163 64  %arrayidxB = getelementptr inbounds i16, ptr %b, i64 %iv65  %loadB = load i16, ptr %arrayidxB, align 266 67  %arrayidxA_ub = getelementptr inbounds i16, ptr %a, i16 %loadB68  %loadA_ub = load i16, ptr %arrayidxA_ub, align 269 70  %mul = mul i16 %loadB, %loadA_ub71 72  %arrayidxA = getelementptr inbounds i16, ptr %a, i64 %iv73  store i16 %mul, ptr %arrayidxA, align 274 75  %exitcond = icmp eq i64 %iv, 2076  br i1 %exitcond, label %for.end, label %for.body77 78for.end:                                          ; preds = %for.body79  ret void80}81