1; RUN: opt -analyze --loop-accesses %s -enable-new-pm=0 | FileCheck %s 2; RUN: opt -passes=print-access-info %s -disable-output 2>&1 | FileCheck %s 3 4; This test defends against accidentally using alloc size instead of store size when performing run-time 5; boundary check of memory accesses. The IR in this file is based on 6; llvm/test/Analysis/LoopAccessAnalysis/memcheck-off-by-one-error.ll. 7; Here, we use i19 instead of i64 because it has a different alloc size to its store size. 8 9;CHECK: function 'fastCopy': 10;CHECK: (Low: %op High: (27 + %op)) 11;CHECK: (Low: %src High: (27 + %src)) 12 13define void @fastCopy(i8* nocapture readonly %src, i8* nocapture %op) { 14entry: 15 br label %while.body.preheader 16 17while.body.preheader: ; preds = %entry 18 br label %while.body 19 20while.body: ; preds = %while.body.preheader, %while.body 21 %len.addr.07 = phi i32 [ %sub, %while.body ], [ 32, %while.body.preheader ] 22 %op.addr.06 = phi i8* [ %add.ptr1, %while.body ], [ %op, %while.body.preheader ] 23 %src.addr.05 = phi i8* [ %add.ptr, %while.body ], [ %src, %while.body.preheader ] 24 %0 = bitcast i8* %src.addr.05 to i19* 25 %1 = load i19, i19* %0, align 8 26 %2 = bitcast i8* %op.addr.06 to i19* 27 store i19 %1, i19* %2, align 8 28 %add.ptr = getelementptr inbounds i8, i8* %src.addr.05, i19 8 29 %add.ptr1 = getelementptr inbounds i8, i8* %op.addr.06, i19 8 30 %sub = add nsw i32 %len.addr.07, -8 31 %cmp = icmp sgt i32 %len.addr.07, 8 32 br i1 %cmp, label %while.body, label %while.end.loopexit 33 34while.end.loopexit: ; preds = %while.body 35 br label %while.end 36 37while.end: ; preds = %while.end.loopexit, %entry 38 ret void 39} 40