37 lines · plain
1; RUN: opt -passes='print<access-info>' %s -disable-output 2>&1 | FileCheck %s2 3; This test defends against accidentally using alloc size instead of store size when performing run-time4; boundary check of memory accesses. The IR in this file is based on5; llvm/test/Analysis/LoopAccessAnalysis/memcheck-off-by-one-error.ll.6; Here, we use i19 instead of i64 because it has a different alloc size to its store size.7 8;CHECK: function 'fastCopy':9;CHECK: (Low: %op High: (27 + %op))10;CHECK: (Low: %src High: (27 + %src))11 12define void @fastCopy(ptr nocapture readonly %src, ptr nocapture %op) {13entry:14 br label %while.body.preheader15 16while.body.preheader: ; preds = %entry17 br label %while.body18 19while.body: ; preds = %while.body.preheader, %while.body20 %len.addr.07 = phi i32 [ %sub, %while.body ], [ 32, %while.body.preheader ]21 %op.addr.06 = phi ptr [ %add.ptr1, %while.body ], [ %op, %while.body.preheader ]22 %src.addr.05 = phi ptr [ %add.ptr, %while.body ], [ %src, %while.body.preheader ]23 %0 = load i19, ptr %src.addr.05, align 824 store i19 %0, ptr %op.addr.06, align 825 %add.ptr = getelementptr inbounds i8, ptr %src.addr.05, i19 826 %add.ptr1 = getelementptr inbounds i8, ptr %op.addr.06, i19 827 %sub = add nsw i32 %len.addr.07, -828 %cmp = icmp sgt i32 %len.addr.07, 829 br i1 %cmp, label %while.body, label %while.end.loopexit30 31while.end.loopexit: ; preds = %while.body32 br label %while.end33 34while.end: ; preds = %while.end.loopexit, %entry35 ret void36}37