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