@@ -23,28 +23,28 @@ int * __counted_by_or_null(len) foo(int * __bidi_indexable p, int len) {
2323// CHECK-NEXT: [[AGG_TEMP_SROA_0_0_COPYLOAD:%.*]] = load ptr, ptr [[P]], align 8
2424// CHECK-NEXT: [[AGG_TEMP_SROA_2_0_P_SROA_IDX:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 8
2525// CHECK-NEXT: [[AGG_TEMP1_SROA_1_0_COPYLOAD:%.*]] = load ptr, ptr [[AGG_TEMP_SROA_2_0_P_SROA_IDX]], align 8
26- // CHECK-NEXT: [[CMP_NOT:%.*]] = icmp ugt ptr [[AGG_TEMP_SROA_0_0_COPYLOAD]], [[AGG_TEMP1_SROA_1_0_COPYLOAD]], !annotation [[META2 :![0-9]+]]
27- // CHECK-NEXT: br i1 [[CMP_NOT]], label %[[TRAP:.*]], label %[[LAND_LHS_TRUE:.*]], !annotation [[META2 ]]
26+ // CHECK-NEXT: [[CMP_NOT:%.*]] = icmp ugt ptr [[AGG_TEMP_SROA_0_0_COPYLOAD]], [[AGG_TEMP1_SROA_1_0_COPYLOAD]], !annotation [[META6 :![0-9]+]]
27+ // CHECK-NEXT: br i1 [[CMP_NOT]], label %[[TRAP:.*]], label %[[LAND_LHS_TRUE:.*]], !annotation [[META6 ]]
2828// CHECK: [[LAND_LHS_TRUE]]:
2929// CHECK-NEXT: [[AGG_TEMP_SROA_3_0_P_SROA_IDX:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 16
30- // CHECK-NEXT: [[AGG_TEMP5_SROA_1_0_COPYLOAD:%.*]] = load ptr, ptr [[AGG_TEMP_SROA_3_0_P_SROA_IDX]], align 8, !tbaa [[TBAA3 :![0-9]+]]
31- // CHECK-NEXT: [[CMP15_NOT:%.*]] = icmp ugt ptr [[AGG_TEMP5_SROA_1_0_COPYLOAD]], [[AGG_TEMP_SROA_0_0_COPYLOAD]], !annotation [[META2 ]]
32- // CHECK-NEXT: br i1 [[CMP15_NOT]], label %[[TRAP]], label %[[LAND_RHS:.*]], !annotation [[META2 ]]
30+ // CHECK-NEXT: [[AGG_TEMP5_SROA_1_0_COPYLOAD:%.*]] = load ptr, ptr [[AGG_TEMP_SROA_3_0_P_SROA_IDX]], align 8, !tbaa [[TBAA7 :![0-9]+]]
31+ // CHECK-NEXT: [[CMP15_NOT:%.*]] = icmp ugt ptr [[AGG_TEMP5_SROA_1_0_COPYLOAD]], [[AGG_TEMP_SROA_0_0_COPYLOAD]], !annotation [[META6 ]]
32+ // CHECK-NEXT: br i1 [[CMP15_NOT]], label %[[TRAP]], label %[[LAND_RHS:.*]], !annotation [[META6 ]]
3333// CHECK: [[LAND_RHS]]:
34- // CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq ptr [[AGG_TEMP_SROA_0_0_COPYLOAD]], null, !annotation [[META2 ]]
35- // CHECK-NEXT: br i1 [[TOBOOL_NOT]], label %[[CONT:.*]], label %[[LOR_RHS:.*]], !annotation [[META2 ]]
34+ // CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq ptr [[AGG_TEMP_SROA_0_0_COPYLOAD]], null, !annotation [[META6 ]]
35+ // CHECK-NEXT: br i1 [[TOBOOL_NOT]], label %[[CONT:.*]], label %[[LOR_RHS:.*]], !annotation [[META6 ]]
3636// CHECK: [[LOR_RHS]]:
37- // CHECK-NEXT: [[SUB_PTR_LHS_CAST:%.*]] = ptrtoint ptr [[AGG_TEMP1_SROA_1_0_COPYLOAD]] to i64, !annotation [[META2 ]]
38- // CHECK-NEXT: [[SUB_PTR_RHS_CAST:%.*]] = ptrtoint ptr [[AGG_TEMP_SROA_0_0_COPYLOAD]] to i64, !annotation [[META2 ]]
39- // CHECK-NEXT: [[SUB_PTR_SUB:%.*]] = sub i64 [[SUB_PTR_LHS_CAST]], [[SUB_PTR_RHS_CAST]], !annotation [[META8 :![0-9]+]]
40- // CHECK-NEXT: [[SUB_PTR_DIV:%.*]] = ashr exact i64 [[SUB_PTR_SUB]], 2, !annotation [[META2 ]]
41- // CHECK-NEXT: [[CMP34:%.*]] = icmp sge i64 [[SUB_PTR_DIV]], [[CONV]], !annotation [[META2 ]]
42- // CHECK-NEXT: [[CMP37:%.*]] = icmp sgt i32 [[LEN]], -1, !annotation [[META2 ]]
37+ // CHECK-NEXT: [[SUB_PTR_LHS_CAST:%.*]] = ptrtoint ptr [[AGG_TEMP1_SROA_1_0_COPYLOAD]] to i64, !annotation [[META6 ]]
38+ // CHECK-NEXT: [[SUB_PTR_RHS_CAST:%.*]] = ptrtoint ptr [[AGG_TEMP_SROA_0_0_COPYLOAD]] to i64, !annotation [[META6 ]]
39+ // CHECK-NEXT: [[SUB_PTR_SUB:%.*]] = sub i64 [[SUB_PTR_LHS_CAST]], [[SUB_PTR_RHS_CAST]], !annotation [[META10 :![0-9]+]]
40+ // CHECK-NEXT: [[SUB_PTR_DIV:%.*]] = ashr exact i64 [[SUB_PTR_SUB]], 2, !annotation [[META6 ]]
41+ // CHECK-NEXT: [[CMP34:%.*]] = icmp sge i64 [[SUB_PTR_DIV]], [[CONV]], !annotation [[META6 ]]
42+ // CHECK-NEXT: [[CMP37:%.*]] = icmp sgt i32 [[LEN]], -1, !annotation [[META6 ]]
4343// CHECK-NEXT: [[SPEC_SELECT:%.*]] = and i1 [[CMP37]], [[CMP34]]
44- // CHECK-NEXT: br i1 [[SPEC_SELECT]], label %[[CONT]], label %[[TRAP]], !prof [[PROF10 :![0-9]+]], !annotation [[META2 ]]
44+ // CHECK-NEXT: br i1 [[SPEC_SELECT]], label %[[CONT]], label %[[TRAP]], !prof [[PROF12 :![0-9]+]], !annotation [[META6 ]]
4545// CHECK: [[TRAP]]:
46- // CHECK-NEXT: tail call void @llvm.ubsantrap(i8 25) #[[ATTR7:[0-9]+]], !annotation [[META2 ]]
47- // CHECK-NEXT: unreachable, !annotation [[META2 ]]
46+ // CHECK-NEXT: tail call void @llvm.ubsantrap(i8 25) #[[ATTR7:[0-9]+]], !annotation [[META6 ]]
47+ // CHECK-NEXT: unreachable, !annotation [[META6 ]]
4848// CHECK: [[CONT]]:
4949// CHECK-NEXT: ret void
5050//
@@ -56,7 +56,7 @@ void foo_assign(int * __bidi_indexable p, int len) {
5656// CHECK-LABEL: define dso_local void @bar(
5757// CHECK-SAME: ptr dead_on_unwind noalias writable writeonly sret(%"__bounds_safety::wide_ptr.bidi_indexable") align 8 captures(none) initializes((0, 24)) [[AGG_RESULT:%.*]], ptr noundef [[P:%.*]], i32 noundef [[LEN:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] {
5858// CHECK-NEXT: [[ENTRY:.*:]]
59- // CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq ptr [[P]], null, !annotation [[META11 :![0-9]+]]
59+ // CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq ptr [[P]], null, !annotation [[META13 :![0-9]+]]
6060// CHECK-NEXT: [[IDX_EXT:%.*]] = sext i32 [[LEN]] to i64
6161// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr [[P]], i64 [[IDX_EXT]]
6262// CHECK-NEXT: [[ADD_PTR_SINK:%.*]] = select i1 [[DOTNOT]], ptr null, ptr [[ADD_PTR]]
@@ -83,8 +83,8 @@ void bar_assign(int * __counted_by_or_null(len) p, int len) {
8383// CHECK-LABEL: define dso_local void @ptr_oob(
8484// CHECK-SAME: ) local_unnamed_addr #[[ATTR5:[0-9]+]] {
8585// CHECK-NEXT: [[TRAP:.*:]]
86- // CHECK-NEXT: tail call void @llvm.ubsantrap(i8 25) #[[ATTR7]], !annotation [[META2 ]]
87- // CHECK-NEXT: unreachable, !annotation [[META2 ]]
86+ // CHECK-NEXT: tail call void @llvm.ubsantrap(i8 25) #[[ATTR7]], !annotation [[META6 ]]
87+ // CHECK-NEXT: unreachable, !annotation [[META6 ]]
8888//
8989void ptr_oob (void ) {
9090 int x ;
@@ -124,14 +124,14 @@ int *__bidi_indexable null_count_too_big(void) {
124124}
125125
126126//.
127- // CHECK: [[META2]] = !{!"bounds-safety-generic" }
128- // CHECK: [[TBAA3 ]] = !{[[META4:![0-9]+]], [[META4]], i64 0 }
129- // CHECK: [[META4 ]] = !{!"p1 int", [[META5:![0-9]+]], i64 0 }
130- // CHECK: [[META5 ]] = !{!"any pointer", [[META6 :![0-9]+]], i64 0}
131- // CHECK: [[META6 ]] = !{!"omnipotent char ", [[META7 :![0-9]+]], i64 0}
132- // CHECK: [[META7 ]] = !{!"Simple C/C++ TBAA" }
133- // CHECK: [[META8 ]] = !{!"bounds-safety-generic", [[META9 :![0-9]+]]}
134- // CHECK: [[META9 ]] = !{!"bounds-safety-missed-optimization-nsw", !"Check can not be removed because the arithmetic operation might wrap in the signed sense. Optimize the check by adding conditions to check for overflow before doing the operation"}
135- // CHECK: [[PROF10 ]] = !{!"branch_weights", i32 1048575, i32 1}
136- // CHECK: [[META11 ]] = !{!"bounds-safety-check-ptr-neq-null"}
127+ // CHECK: [[META4:![0-9]+]] = !{!"omnipotent char", [[META5:![0-9]+]], i64 0 }
128+ // CHECK: [[META5 ]] = !{!"Simple C/C++ TBAA" }
129+ // CHECK: [[META6 ]] = !{!"bounds-safety-generic" }
130+ // CHECK: [[TBAA7 ]] = !{[[META8 :![0-9]+]], [[META8 ]], i64 0}
131+ // CHECK: [[META8 ]] = !{!"p1 int ", [[META9 :![0-9]+]], i64 0}
132+ // CHECK: [[META9 ]] = !{!"any pointer", [[META4]], i64 0 }
133+ // CHECK: [[META10 ]] = !{!"bounds-safety-generic", [[META11 :![0-9]+]]}
134+ // CHECK: [[META11 ]] = !{!"bounds-safety-missed-optimization-nsw", !"Check can not be removed because the arithmetic operation might wrap in the signed sense. Optimize the check by adding conditions to check for overflow before doing the operation"}
135+ // CHECK: [[PROF12 ]] = !{!"branch_weights", i32 1048575, i32 1}
136+ // CHECK: [[META13 ]] = !{!"bounds-safety-check-ptr-neq-null"}
137137//.
0 commit comments