|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | +; Check that negative oob gep do not generate invalid check. |
| 3 | +; RUN: opt < %s -passes=bounds-checking -S | FileCheck %s |
| 4 | +target datalayout = "e-p:64:64:64-p1:16:16:16-p2:64:64:64:48-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" |
| 5 | + |
| 6 | + |
| 7 | +@str = global [100 x i8] zeroinitializer, align 1 |
| 8 | + |
| 9 | +define i16 @main() { |
| 10 | +; CHECK-LABEL: @main( |
| 11 | +; CHECK-NEXT: entry: |
| 12 | +; CHECK-NEXT: br label [[FOR_COND:%.*]] |
| 13 | +; CHECK: for.cond: |
| 14 | +; CHECK-NEXT: [[I_0:%.*]] = phi i8 [ 65, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[TMP4:%.*]] ] |
| 15 | +; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i8 [[I_0]], 76 |
| 16 | +; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_END:%.*]], label [[TMP4]] |
| 17 | +; CHECK: for.inc: |
| 18 | +; CHECK-NEXT: [[I_0_C:%.*]] = sext i8 [[I_0]] to i64 |
| 19 | +; CHECK-NEXT: [[TMP0:%.*]] = add i64 -65, [[I_0_C]] |
| 20 | +; CHECK-NEXT: [[GEP:%.*]] = getelementptr i8, ptr getelementptr (i8, ptr @str, i8 -65), i8 [[I_0]] |
| 21 | +; CHECK-NEXT: [[TMP1:%.*]] = sub i64 100, [[TMP0]] |
| 22 | +; CHECK-NEXT: store i8 [[I_0]], ptr [[GEP]], align 1 |
| 23 | +; CHECK-NEXT: [[INC]] = add nuw nsw i8 [[I_0]], 1 |
| 24 | +; CHECK-NEXT: br label [[FOR_COND]] |
| 25 | +; CHECK: for.end: |
| 26 | +; CHECK-NEXT: ret i16 0 |
| 27 | +; |
| 28 | +entry: |
| 29 | + br label %for.cond |
| 30 | + |
| 31 | +for.cond: |
| 32 | + %i.0 = phi i8 [ 65, %entry ], [ %inc, %for.inc ] |
| 33 | + %exitcond.not = icmp eq i8 %i.0, 76 |
| 34 | + br i1 %exitcond.not, label %for.end, label %for.inc |
| 35 | + |
| 36 | +for.inc: ; preds = %for.cond |
| 37 | + %gep = getelementptr i8, ptr getelementptr (i8, ptr @str, i8 -65), i8 %i.0 |
| 38 | + store i8 %i.0, ptr %gep, align 1 |
| 39 | + %inc = add nuw nsw i8 %i.0, 1 |
| 40 | + br label %for.cond |
| 41 | + |
| 42 | +for.end: |
| 43 | + ret i16 0 |
| 44 | +} |
| 45 | + |
0 commit comments