1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=bounds-checking -S | FileCheck %s
3 ; RUN: opt < %s -passes='bounds-checking<merge>' -S | not FileCheck %s
5 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"
7 declare noalias ptr @malloc(i64) nounwind allocsize(0)
9 define void @f() nounwind {
11 ; CHECK-NEXT: [[TMP1:%.*]] = tail call ptr @malloc(i64 32)
12 ; CHECK-NEXT: [[IDX:%.*]] = getelementptr inbounds i32, ptr [[TMP1]], i64 8
13 ; CHECK-NEXT: br label [[TRAP:%.*]]
15 ; CHECK-NEXT: store i32 3, ptr [[IDX]], align 4
16 ; CHECK-NEXT: [[TMP3:%.*]] = tail call ptr @malloc(i64 32)
17 ; CHECK-NEXT: [[IDX2:%.*]] = getelementptr inbounds i32, ptr [[TMP3]], i64 8
18 ; CHECK-NEXT: br label [[TRAP1:%.*]]
20 ; CHECK-NEXT: store i32 3, ptr [[IDX2]], align 4
21 ; CHECK-NEXT: [[TMP5:%.*]] = tail call ptr @malloc(i64 32)
22 ; CHECK-NEXT: [[IDX3:%.*]] = getelementptr inbounds i32, ptr [[TMP5]], i64 8
23 ; CHECK-NEXT: br label [[TRAP2:%.*]]
25 ; CHECK-NEXT: store i32 3, ptr [[IDX3]], align 4
26 ; CHECK-NEXT: ret void
28 ; CHECK-NEXT: call void @llvm.ubsantrap(i8 3) #[[ATTR3:[0-9]+]]
29 ; CHECK-NEXT: unreachable
31 ; CHECK-NEXT: call void @llvm.ubsantrap(i8 5) #[[ATTR3]]
32 ; CHECK-NEXT: unreachable
34 ; CHECK-NEXT: call void @llvm.ubsantrap(i8 7) #[[ATTR3]]
35 ; CHECK-NEXT: unreachable
37 %1 = tail call ptr @malloc(i64 32)
38 %idx = getelementptr inbounds i32, ptr %1, i64 8
39 store i32 3, ptr %idx, align 4
40 %2 = tail call ptr @malloc(i64 32)
41 %idx2 = getelementptr inbounds i32, ptr %2, i64 8
42 store i32 3, ptr %idx2, align 4
43 %3 = tail call ptr @malloc(i64 32)
44 %idx3 = getelementptr inbounds i32, ptr %3, i64 8
45 store i32 3, ptr %idx3, align 4