From 59ef2c71d5350bba24082cac3282ebc8fe28e70e Mon Sep 17 00:00:00 2001 From: Yeoul Na Date: Tue, 25 Mar 2025 11:14:22 -0700 Subject: [PATCH 1/4] [BoundsSafety] Don't bind lvalues with temporary locations This should fix a miscompilation bug found during adoption. When a base is lvalue and is wrapped in OVE, the compiler incorrectly creates a temporary and maps its address to the lvalue instead of the actual address of the lvalue. The solution is to emit lvalue directly instead of creating extra temporary. rdar://146329029 (cherry picked from commit 8dd1309a1124821ef0d6b852b03e6821b5305a35) --- clang/lib/CodeGen/CGExpr.cpp | 10 +- clang/lib/CodeGen/CGExprAgg.cpp | 8 +- .../CodeGen/builtin-memcpy-count-annotation.c | 22 +- .../CodeGen/call-with-count-ptr.c | 12 +- .../counted-to-counted-assignments-O2.c | 2 +- .../CodeGen/ended_by_assign_checks_seq-O2.c | 6 +- .../CodeGen/nested-flexible-array-member-O2.c | 44 +++ ...sted-flexible-array-member-nested-len-O2.c | 49 ++++ .../nested-flexible-array-member-nested-len.c | 277 ++++++++++++++++++ .../CodeGen/nested-flexible-array-member.c | 269 +++++++++++++++++ 10 files changed, 663 insertions(+), 36 deletions(-) create mode 100644 clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-O2.c create mode 100644 clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-nested-len-O2.c create mode 100644 clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-nested-len.c create mode 100644 clang/test/BoundsSafety/CodeGen/nested-flexible-array-member.c diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 34c51481779f0..fc387b2e5a1c5 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -6663,14 +6663,8 @@ LValue CodeGenFunction::EmitMaterializeSequenceExprLValue( const MaterializeSequenceExpr *MSE) { if (MSE->isBinding()) { for (auto *OVE : MSE->opaquevalues()) { - if (CodeGenFunction::OpaqueValueMappingData::shouldBindAsLValue(OVE)) { - RValue PtrRV = EmitAnyExpr(OVE->getSourceExpr()); - LValue LV = MakeAddrLValue(PtrRV.getAggregateAddress(), OVE->getType()); - CodeGenFunction::OpaqueValueMappingData::bind(*this, OVE, LV); - } else { - CodeGenFunction::OpaqueValueMappingData::bind( - *this, OVE, OVE->getSourceExpr()); - } + CodeGenFunction::OpaqueValueMappingData::bind( + *this, OVE, OVE->getSourceExpr()); } } diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index b16dca7f8c680..4def8df7e7933 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -591,13 +591,7 @@ void AggExprEmitter::VisitPredefinedBoundsCheckExpr( void AggExprEmitter::VisitMaterializeSequenceExpr(MaterializeSequenceExpr *MSE) { if (MSE->isBinding()) { for (auto *OVE : MSE->opaquevalues()) { - if (CodeGenFunction::OpaqueValueMappingData::shouldBindAsLValue(OVE)) { - RValue PtrRV = CGF.EmitAnyExpr(OVE->getSourceExpr()); - LValue LV = CGF.MakeAddrLValue(PtrRV.getAggregateAddress(), OVE->getType()); - CodeGenFunction::OpaqueValueMappingData::bind(CGF, OVE, LV); - } else { - CodeGenFunction::OpaqueValueMappingData::bind(CGF, OVE, OVE->getSourceExpr()); - } + CodeGenFunction::OpaqueValueMappingData::bind(CGF, OVE, OVE->getSourceExpr()); } } diff --git a/clang/test/BoundsSafety/CodeGen/builtin-memcpy-count-annotation.c b/clang/test/BoundsSafety/CodeGen/builtin-memcpy-count-annotation.c index 481441dbe75d0..3b947bc2c0a35 100644 --- a/clang/test/BoundsSafety/CodeGen/builtin-memcpy-count-annotation.c +++ b/clang/test/BoundsSafety/CodeGen/builtin-memcpy-count-annotation.c @@ -177,8 +177,8 @@ // CHECK-NEXT: [[WIDE_PTR_LB_ADDR88:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP81]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB89:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR88]], align 8 // CHECK-NEXT: [[CMP90:%.*]] = icmp ule ptr [[WIDE_PTR_PTR76]], [[WIDE_PTR_PTR85]] -// CHECK-NEXT: br i1 [[CMP90]], label [[LAND_LHS_TRUE91:%.*]], label [[LAND_END144:%.*]] -// CHECK: land.lhs.true91: +// CHECK-NEXT: br i1 [[CMP90]], label %[[LAND_LHS_TRUE91:.*]], label %[[LAND_END144:.*]], +// CHECK: [[LAND_LHS_TRUE91]]: // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP92]], ptr align 8 [[AGG_TEMP]], i64 24, i1 false) // CHECK-NEXT: [[WIDE_PTR_LB_ADDR93:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP92]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB94:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR93]], align 8 @@ -198,8 +198,8 @@ // CHECK-NEXT: [[WIDE_PTR_LB_ADDR106:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP101]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB107:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR106]], align 8 // CHECK-NEXT: [[CMP108:%.*]] = icmp ule ptr [[WIDE_PTR_PTR96]], [[WIDE_PTR_PTR103]] -// CHECK-NEXT: br i1 [[CMP108]], label [[LAND_RHS109:%.*]], label [[LAND_END144]] -// CHECK: land.rhs109: +// CHECK-NEXT: br i1 [[CMP108]], label %[[LAND_RHS109:.*]], label %[[LAND_END144]] +// CHECK: [[LAND_RHS109]]: // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP111]], ptr align 8 [[AGG_TEMP]], i64 24, i1 false) // CHECK-NEXT: [[WIDE_PTR_UB_ADDR112:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP111]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB113:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR112]], align 8 @@ -245,15 +245,15 @@ // CHECK-NEXT: [[SUB_PTR_LHS_CAST140:%.*]] = ptrtoint ptr [[WIDE_PTR_PTR121]] to i64 // CHECK-NEXT: [[SUB_PTR_RHS_CAST141:%.*]] = ptrtoint ptr [[WIDE_PTR_PTR135]] to i64 // CHECK-NEXT: [[SUB_PTR_SUB142:%.*]] = sub i64 [[SUB_PTR_LHS_CAST140]], [[SUB_PTR_RHS_CAST141]] -// CHECK-NEXT: [[CMP143:%.*]] = icmp ule i64 10, [[SUB_PTR_SUB142]] -// CHECK-NEXT: br label [[LAND_END144]] -// CHECK: land.end144: -// CHECK-NEXT: [[TMP25:%.*]] = phi i1 [ false, [[LAND_LHS_TRUE91]] ], [ false, [[CONT]] ], [ [[CMP143]], [[LAND_RHS109]] ], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP25]], label [[CONT146:%.*]], label [[TRAP145:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap145: +// CHECK-NEXT: [[CMP143:%.*]] = icmp ule i64 10, [[SUB_PTR_SUB142]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br label %[[LAND_END144]] +// CHECK: [[LAND_END144]]: {{.*}} +// CHECK-NEXT: [[TMP25:%.*]] = phi i1 [ false, %[[LAND_LHS_TRUE91]] ], [ false, [[CONT]] ], [ [[CMP143]], %[[LAND_RHS109]] ], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[TMP25]], label %[[CONT146:.*]], label %[[TRAP145:.*]], {{!prof ![0-9]+}}, {{!annotation ![0-9]+}} +// CHECK: [[TRAP145]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR5]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable -// CHECK: cont146: +// CHECK: [[CONT146]]: // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP147]], ptr align 8 [[AGG_TEMP]], i64 24, i1 false) // CHECK-NEXT: [[WIDE_PTR_PTR_ADDR148:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP147]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR149:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR148]], align 8 diff --git a/clang/test/BoundsSafety/CodeGen/call-with-count-ptr.c b/clang/test/BoundsSafety/CodeGen/call-with-count-ptr.c index 46a77b4226280..7517450b9b3e6 100644 --- a/clang/test/BoundsSafety/CodeGen/call-with-count-ptr.c +++ b/clang/test/BoundsSafety/CodeGen/call-with-count-ptr.c @@ -240,11 +240,11 @@ int arr[] = {0, 1, 2, 3, 4, 5}; // CHECK_X64_O0-NEXT: br label [[LAND_END]] // CHECK_X64_O0: land.end: // CHECK_X64_O0-NEXT: [[TMP38:%.*]] = phi i1 [ false, [[LAND_LHS_TRUE]] ], [ false, [[CONT]] ], [ [[CMP116]], [[LAND_RHS]] ], {{!annotation ![0-9]+}} -// CHECK_X64_O0-NEXT: br i1 [[TMP38]], label [[CONT118:%.*]], label [[TRAP117:%.*]], {{!annotation ![0-9]+}} -// CHECK_X64_O0: trap117: +// CHECK_X64_O0-NEXT: br i1 [[TMP38]], label %[[CONT118:.*]], label %[[TRAP117:.*]], {{!prof ![0-9]+}}, {{!annotation ![0-9]+}} +// CHECK_X64_O0: [[TRAP117]]: // CHECK_X64_O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR5]], {{!annotation ![0-9]+}} // CHECK_X64_O0-NEXT: unreachable -// CHECK_X64_O0: cont118: +// CHECK_X64_O0: [[CONT118]]: // CHECK_X64_O0-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP119]], ptr align 8 [[AGG_TEMP]], i64 24, i1 false) // CHECK_X64_O0-NEXT: [[WIDE_PTR_PTR_ADDR120:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP119]], i32 0, i32 0 // CHECK_X64_O0-NEXT: [[WIDE_PTR_PTR121:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR120]], align 8 @@ -490,11 +490,11 @@ int arr[] = {0, 1, 2, 3, 4, 5}; // CHECK_ARM64_O0-NEXT: br label [[LAND_END]] // CHECK_ARM64_O0: land.end: // CHECK_ARM64_O0-NEXT: [[TMP38:%.*]] = phi i1 [ false, [[LAND_LHS_TRUE]] ], [ false, [[CONT]] ], [ [[CMP116]], [[LAND_RHS]] ], {{!annotation ![0-9]+}} -// CHECK_ARM64_O0-NEXT: br i1 [[TMP38]], label [[CONT118:%.*]], label [[TRAP117:%.*]], {{!annotation ![0-9]+}} -// CHECK_ARM64_O0: trap117: +// CHECK_ARM64_O0-NEXT: br i1 [[TMP38]], label %[[CONT118:.*]], label %[[TRAP117:.*]], {{!prof ![0-9]+}}, {{!annotation ![0-9]+}} +// CHECK_ARM64_O0: [[TRAP117]]: // CHECK_ARM64_O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR5]], {{!annotation ![0-9]+}} // CHECK_ARM64_O0-NEXT: unreachable -// CHECK_ARM64_O0: cont118: +// CHECK_ARM64_O0: [[CONT118]]: // CHECK_ARM64_O0-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP119]], ptr align 8 [[AGG_TEMP]], i64 24, i1 false) // CHECK_ARM64_O0-NEXT: [[WIDE_PTR_PTR_ADDR120:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP119]], i32 0, i32 0 // CHECK_ARM64_O0-NEXT: [[WIDE_PTR_PTR121:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR120]], align 8 diff --git a/clang/test/BoundsSafety/CodeGen/count-dependent-assignment-checks/counted-to-counted-assignments-O2.c b/clang/test/BoundsSafety/CodeGen/count-dependent-assignment-checks/counted-to-counted-assignments-O2.c index 831aa1ef69353..4909276fb03f6 100644 --- a/clang/test/BoundsSafety/CodeGen/count-dependent-assignment-checks/counted-to-counted-assignments-O2.c +++ b/clang/test/BoundsSafety/CodeGen/count-dependent-assignment-checks/counted-to-counted-assignments-O2.c @@ -46,7 +46,7 @@ void TestPtrOK() { // CHECK: trap: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR5]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont57: +// CHECK: cont56: // CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 40, ptr nonnull [[ARR]]) #[[ATTR6]] // CHECK-NEXT: ret void // diff --git a/clang/test/BoundsSafety/CodeGen/ended_by_assign_checks_seq-O2.c b/clang/test/BoundsSafety/CodeGen/ended_by_assign_checks_seq-O2.c index f40f0979bf5fa..67a4f55ee2ee2 100644 --- a/clang/test/BoundsSafety/CodeGen/ended_by_assign_checks_seq-O2.c +++ b/clang/test/BoundsSafety/CodeGen/ended_by_assign_checks_seq-O2.c @@ -68,11 +68,11 @@ void TestRangeOK4(void) { // CHECK-NEXT: [[CMP80_NOT:%.*]] = icmp ugt ptr [[BOUND_PTR_ARITH60]], [[BOUND_PTR_ARITH8]], {{!annotation ![0-9]+}} // CHECK-NEXT: [[CMP95_NOT:%.*]] = icmp ugt ptr [[ARR]], [[BOUND_PTR_ARITH60]], {{!annotation ![0-9]+}} // CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[CMP80_NOT]], [[CMP95_NOT]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[OR_COND]], label [[TRAP:%.*]], label [[CONT96:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap: +// CHECK-NEXT: br i1 [[OR_COND]], label %[[TRAP:.*]], label %[[CONT96:.*]], {{!prof ![0-9]+}}, {{!annotation ![0-9]+}} +// CHECK: [[TRAP]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR7:[0-9]+]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont96: +// CHECK: [[CONT96]]: // CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 40, ptr nonnull [[ARR]]) #[[ATTR6]] // CHECK-NEXT: ret void // diff --git a/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-O2.c b/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-O2.c new file mode 100644 index 0000000000000..3e8b455c78297 --- /dev/null +++ b/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-O2.c @@ -0,0 +1,44 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 + +// RUN: %clang_cc1 -O2 -fbounds-safety -triple arm64e-apple-ios -emit-llvm %s -o - | FileCheck %s + +#include +typedef struct { + int count; + char arr[__counted_by(count)]; +} flex_t; + +typedef struct { + flex_t f; +} outer_flex_t; + +void use(void *__unsafe_indexable); + +// CHECK-LABEL: define void @process_frame( +// CHECK-SAME: ptr noundef [[FRAME:%.*]], i32 noundef [[FRAME_SIZE:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[IDX_EXT:%.*]] = zext i32 [[FRAME_SIZE]] to i64 +// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds nuw i8, ptr [[FRAME]], i64 [[IDX_EXT]] +// CHECK-NEXT: [[TMP0:%.*]] = getelementptr i8, ptr [[FRAME]], i64 4 +// CHECK-NEXT: [[DOTNOT:%.*]] = icmp ugt ptr [[TMP0]], [[ADD_PTR]], !annotation [[META2:![0-9]+]] +// CHECK-NEXT: br i1 [[DOTNOT]], label %[[TRAP:.*]], label %[[CONT10:.*]], !prof [[PROF3:![0-9]+]], !annotation [[META2]] +// CHECK: [[TRAP]]: +// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 25) #[[ATTR3:[0-9]+]], !annotation [[META4:![0-9]+]] +// CHECK-NEXT: unreachable, !annotation [[META4]] +// CHECK: [[CONT10]]: +// CHECK-NEXT: tail call void @use(ptr noundef [[FRAME]]) #[[ATTR4:[0-9]+]] +// CHECK-NEXT: tail call void @use(ptr noundef [[TMP0]]) #[[ATTR4]] +// CHECK-NEXT: tail call void @use(ptr noundef [[TMP0]]) #[[ATTR4]] +// CHECK-NEXT: ret void +// +void process_frame(char *__counted_by(frame_size) frame, unsigned frame_size) { + outer_flex_t *of = (outer_flex_t *) frame; + use(&of->f); + use(of->f.arr); + use(&of->f.arr[0]); +} +//. +// CHECK: [[META2]] = !{!"bounds-safety-check-ptr-lt-upper-bound"} +// CHECK: [[PROF3]] = !{!"branch_weights", i32 8191, i32 -8192} +// CHECK: [[META4]] = !{!"bounds-safety-check-ptr-lt-upper-bound", !"bounds-safety-check-ptr-ge-lower-bound"} +//. diff --git a/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-nested-len-O2.c b/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-nested-len-O2.c new file mode 100644 index 0000000000000..5391831035d85 --- /dev/null +++ b/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-nested-len-O2.c @@ -0,0 +1,49 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 + +// RUN: %clang_cc1 -O2 -fbounds-safety -triple arm64e-apple-ios -emit-llvm %s -o - | FileCheck %s + +#include + +typedef struct { + int count; +} header_t; + +typedef struct { + header_t header; + char arr[__counted_by(header.count)]; +} flex_t; + +typedef struct { + flex_t f; +} outer_flex_t; + +void use(void *__unsafe_indexable); + +// CHECK-LABEL: define void @process_frame( +// CHECK-SAME: ptr noundef [[FRAME:%.*]], i32 noundef [[FRAME_SIZE:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[IDX_EXT:%.*]] = zext i32 [[FRAME_SIZE]] to i64 +// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds nuw i8, ptr [[FRAME]], i64 [[IDX_EXT]] +// CHECK-NEXT: [[TMP0:%.*]] = getelementptr i8, ptr [[FRAME]], i64 4 +// CHECK-NEXT: [[DOTNOT:%.*]] = icmp ugt ptr [[TMP0]], [[ADD_PTR]], !annotation [[META2:![0-9]+]] +// CHECK-NEXT: br i1 [[DOTNOT]], label %[[TRAP:.*]], label %[[CONT10:.*]], !prof [[PROF3:![0-9]+]], !annotation [[META2]] +// CHECK: [[TRAP]]: +// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 25) #[[ATTR3:[0-9]+]], !annotation [[META4:![0-9]+]] +// CHECK-NEXT: unreachable, !annotation [[META4]] +// CHECK: [[CONT10]]: +// CHECK-NEXT: tail call void @use(ptr noundef [[FRAME]]) #[[ATTR4:[0-9]+]] +// CHECK-NEXT: tail call void @use(ptr noundef [[TMP0]]) #[[ATTR4]] +// CHECK-NEXT: tail call void @use(ptr noundef [[TMP0]]) #[[ATTR4]] +// CHECK-NEXT: ret void +// +void process_frame(char *__counted_by(frame_size) frame, unsigned frame_size) { + outer_flex_t *of = (outer_flex_t *) frame; + use(&of->f); + use(of->f.arr); + use(&of->f.arr[0]); +} +//. +// CHECK: [[META2]] = !{!"bounds-safety-check-ptr-lt-upper-bound"} +// CHECK: [[PROF3]] = !{!"branch_weights", i32 8191, i32 -8192} +// CHECK: [[META4]] = !{!"bounds-safety-check-ptr-lt-upper-bound", !"bounds-safety-check-ptr-ge-lower-bound"} +//. diff --git a/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-nested-len.c b/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-nested-len.c new file mode 100644 index 0000000000000..d141dfae4fed0 --- /dev/null +++ b/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-nested-len.c @@ -0,0 +1,277 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 + +// RUN: %clang_cc1 -O0 -fbounds-safety -triple arm64e-apple-ios -emit-llvm %s -o - | FileCheck %s + +#include + +typedef struct { + int count; +} header_t; + +typedef struct { + header_t header; + char arr[__counted_by(header.count)]; +} flex_t; + +typedef struct { + flex_t f; +} outer_flex_t; + +void use(void *__unsafe_indexable); + +// CHECK-LABEL: define void @process_frame( +// CHECK-SAME: ptr noundef [[FRAME:%.*]], i32 noundef [[FRAME_SIZE:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[FRAME_ADDR:%.*]] = alloca ptr, align 8 +// CHECK-NEXT: [[FRAME_SIZE_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[OF:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 +// CHECK-NEXT: [[AGG_TEMP:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 +// CHECK-NEXT: [[AGG_TEMP1:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.1", align 8 +// CHECK-NEXT: [[AGG_TEMP2:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.2", align 8 +// CHECK-NEXT: [[AGG_TEMP3:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 +// CHECK-NEXT: [[AGG_TEMP26:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.1", align 8 +// CHECK-NEXT: [[AGG_TEMP27:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 +// CHECK-NEXT: [[AGG_TEMP28:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 +// CHECK-NEXT: [[AGG_TEMP42:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.2", align 8 +// CHECK-NEXT: [[AGG_TEMP65:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.1", align 8 +// CHECK-NEXT: [[AGG_TEMP66:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 +// CHECK-NEXT: [[TMP:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 +// CHECK-NEXT: [[AGG_TEMP67:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 +// CHECK-NEXT: [[AGG_TEMP81:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.2", align 8 +// CHECK-NEXT: store ptr [[FRAME]], ptr [[FRAME_ADDR]], align 8 +// CHECK-NEXT: store i32 [[FRAME_SIZE]], ptr [[FRAME_SIZE_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[FRAME_ADDR]], align 8 +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[FRAME_SIZE_ADDR]], align 4 +// CHECK-NEXT: [[IDX_EXT:%.*]] = zext i32 [[TMP1]] to i64 +// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP0]], i64 [[IDX_EXT]] +// CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[TMP0]], ptr [[TMP2]], align 8 +// CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[ADD_PTR]], ptr [[TMP3]], align 8 +// CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[TMP0]], ptr [[TMP4]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR]], align 8 +// CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR]], ptr [[TMP5]], align 8 +// CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[WIDE_PTR_UB]], ptr [[TMP6]], align 8 +// CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[WIDE_PTR_LB]], ptr [[TMP7]], align 8 +// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP3]], ptr align 8 [[OF]], i64 24, i1 false) +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR4:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR5:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR4]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR6:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB7:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR6]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR8:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB9:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR8]], align 8 +// CHECK-NEXT: [[TMP8:%.*]] = getelementptr [[STRUCT_OUTER_FLEX_T:%.*]], ptr [[WIDE_PTR_PTR5]], i64 1 +// CHECK-NEXT: [[TMP9:%.*]] = icmp ule ptr [[TMP8]], [[WIDE_PTR_UB7]], !annotation [[META2:![0-9]+]] +// CHECK-NEXT: br i1 [[TMP9]], label %[[CONT:.*]], label %[[TRAP:.*]], !prof [[PROF3:![0-9]+]], !annotation [[META2]] +// CHECK: [[TRAP]]: +// CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4:[0-9]+]], !annotation [[META2]] +// CHECK-NEXT: unreachable, !annotation [[META2]] +// CHECK: [[CONT]]: +// CHECK-NEXT: [[TMP10:%.*]] = icmp ule ptr [[WIDE_PTR_LB9]], [[WIDE_PTR_PTR5]], !annotation [[META4:![0-9]+]] +// CHECK-NEXT: br i1 [[TMP10]], label %[[CONT11:.*]], label %[[TRAP10:.*]], !prof [[PROF3]], !annotation [[META4]] +// CHECK: [[TRAP10]]: +// CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META4]] +// CHECK-NEXT: unreachable, !annotation [[META4]] +// CHECK: [[CONT11]]: +// CHECK-NEXT: [[F:%.*]] = getelementptr inbounds nuw [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR5]], i32 0, i32 0 +// CHECK-NEXT: [[ARR:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T:%.*]], ptr [[F]], i32 0, i32 1 +// CHECK-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR]], i64 0, i64 0 +// CHECK-NEXT: [[HEADER:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F]], i32 0, i32 0 +// CHECK-NEXT: [[COUNT:%.*]] = getelementptr inbounds nuw [[STRUCT_HEADER_T:%.*]], ptr [[HEADER]], i32 0, i32 0 +// CHECK-NEXT: [[TMP11:%.*]] = load i32, ptr [[COUNT]], align 4 +// CHECK-NEXT: [[IDX_EXT12:%.*]] = sext i32 [[TMP11]] to i64 +// CHECK-NEXT: [[ADD_PTR13:%.*]] = getelementptr inbounds i8, ptr [[ARRAYDECAY]], i64 [[IDX_EXT12]] +// CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[F]], ptr [[TMP12]], align 8 +// CHECK-NEXT: [[TMP13:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[ADD_PTR13]], ptr [[TMP13]], align 8 +// CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[F]], ptr [[TMP14]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR14:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR15:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR14]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR16:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB17:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR16]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR18:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB19:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR18]], align 8 +// CHECK-NEXT: [[TMP15:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR15]], ptr [[TMP15]], align 8 +// CHECK-NEXT: [[TMP16:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[WIDE_PTR_UB17]], ptr [[TMP16]], align 8 +// CHECK-NEXT: [[TMP17:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[WIDE_PTR_LB19]], ptr [[TMP17]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR20:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR21:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR20]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR22:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB23:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR22]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR24:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB25:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR24]], align 8 +// CHECK-NEXT: call void @use(ptr noundef [[WIDE_PTR_PTR21]]) +// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP28]], ptr align 8 [[OF]], i64 24, i1 false) +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR29:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR30:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR29]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR31:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB32:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR31]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR33:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB34:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR33]], align 8 +// CHECK-NEXT: [[TMP18:%.*]] = getelementptr [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR30]], i64 1 +// CHECK-NEXT: [[TMP19:%.*]] = icmp ule ptr [[TMP18]], [[WIDE_PTR_UB32]], !annotation [[META2]] +// CHECK-NEXT: br i1 [[TMP19]], label %[[CONT36:.*]], label %[[TRAP35:.*]], !prof [[PROF3]], !annotation [[META2]] +// CHECK: [[TRAP35]]: +// CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META2]] +// CHECK-NEXT: unreachable, !annotation [[META2]] +// CHECK: [[CONT36]]: +// CHECK-NEXT: [[TMP20:%.*]] = icmp ule ptr [[WIDE_PTR_LB34]], [[WIDE_PTR_PTR30]], !annotation [[META4]] +// CHECK-NEXT: br i1 [[TMP20]], label %[[CONT38:.*]], label %[[TRAP37:.*]], !prof [[PROF3]], !annotation [[META4]] +// CHECK: [[TRAP37]]: +// CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META4]] +// CHECK-NEXT: unreachable, !annotation [[META4]] +// CHECK: [[CONT38]]: +// CHECK-NEXT: [[F39:%.*]] = getelementptr inbounds nuw [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR30]], i32 0, i32 0 +// CHECK-NEXT: [[ARR40:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 1 +// CHECK-NEXT: [[ARRAYDECAY41:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR40]], i64 0, i64 0 +// CHECK-NEXT: [[ARR43:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 1 +// CHECK-NEXT: [[ARRAYDECAY44:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR43]], i64 0, i64 0 +// CHECK-NEXT: [[HEADER45:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 0 +// CHECK-NEXT: [[COUNT46:%.*]] = getelementptr inbounds nuw [[STRUCT_HEADER_T]], ptr [[HEADER45]], i32 0, i32 0 +// CHECK-NEXT: [[TMP21:%.*]] = load i32, ptr [[COUNT46]], align 4 +// CHECK-NEXT: [[IDX_EXT47:%.*]] = sext i32 [[TMP21]] to i64 +// CHECK-NEXT: [[ADD_PTR48:%.*]] = getelementptr inbounds i8, ptr [[ARRAYDECAY44]], i64 [[IDX_EXT47]] +// CHECK-NEXT: [[TMP22:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[F39]], ptr [[TMP22]], align 8 +// CHECK-NEXT: [[TMP23:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[ADD_PTR48]], ptr [[TMP23]], align 8 +// CHECK-NEXT: [[TMP24:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[F39]], ptr [[TMP24]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR49:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB50:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR49]], align 8 +// CHECK-NEXT: [[TMP25:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[WIDE_PTR_UB50]], ptr [[TMP25]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR51:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR52:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR51]], align 8 +// CHECK-NEXT: [[TMP26:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[ARRAYDECAY41]], ptr [[TMP26]], align 8 +// CHECK-NEXT: [[TMP27:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR52]], ptr [[TMP27]], align 8 +// CHECK-NEXT: [[TMP28:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[ARRAYDECAY41]], ptr [[TMP28]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR53:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR54:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR53]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR55:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB56:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR55]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR57:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB58:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR57]], align 8 +// CHECK-NEXT: [[TMP29:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR54]], ptr [[TMP29]], align 8 +// CHECK-NEXT: [[TMP30:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[WIDE_PTR_UB56]], ptr [[TMP30]], align 8 +// CHECK-NEXT: [[TMP31:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[WIDE_PTR_LB58]], ptr [[TMP31]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR59:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR60:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR59]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR61:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB62:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR61]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR63:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB64:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR63]], align 8 +// CHECK-NEXT: call void @use(ptr noundef [[WIDE_PTR_PTR60]]) +// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP67]], ptr align 8 [[OF]], i64 24, i1 false) +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR68:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP67]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR69:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR68]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR70:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP67]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB71:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR70]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR72:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP67]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB73:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR72]], align 8 +// CHECK-NEXT: [[TMP32:%.*]] = getelementptr [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR69]], i64 1 +// CHECK-NEXT: [[TMP33:%.*]] = icmp ule ptr [[TMP32]], [[WIDE_PTR_UB71]], !annotation [[META2]] +// CHECK-NEXT: br i1 [[TMP33]], label %[[CONT75:.*]], label %[[TRAP74:.*]], !prof [[PROF3]], !annotation [[META2]] +// CHECK: [[TRAP74]]: +// CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META2]] +// CHECK-NEXT: unreachable, !annotation [[META2]] +// CHECK: [[CONT75]]: +// CHECK-NEXT: [[TMP34:%.*]] = icmp ule ptr [[WIDE_PTR_LB73]], [[WIDE_PTR_PTR69]], !annotation [[META4]] +// CHECK-NEXT: br i1 [[TMP34]], label %[[CONT77:.*]], label %[[TRAP76:.*]], !prof [[PROF3]], !annotation [[META4]] +// CHECK: [[TRAP76]]: +// CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META4]] +// CHECK-NEXT: unreachable, !annotation [[META4]] +// CHECK: [[CONT77]]: +// CHECK-NEXT: [[F78:%.*]] = getelementptr inbounds nuw [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR69]], i32 0, i32 0 +// CHECK-NEXT: [[ARR79:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F78]], i32 0, i32 1 +// CHECK-NEXT: [[ARRAYDECAY80:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR79]], i64 0, i64 0 +// CHECK-NEXT: [[ARR82:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F78]], i32 0, i32 1 +// CHECK-NEXT: [[ARRAYDECAY83:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR82]], i64 0, i64 0 +// CHECK-NEXT: [[HEADER84:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F78]], i32 0, i32 0 +// CHECK-NEXT: [[COUNT85:%.*]] = getelementptr inbounds nuw [[STRUCT_HEADER_T]], ptr [[HEADER84]], i32 0, i32 0 +// CHECK-NEXT: [[TMP35:%.*]] = load i32, ptr [[COUNT85]], align 4 +// CHECK-NEXT: [[IDX_EXT86:%.*]] = sext i32 [[TMP35]] to i64 +// CHECK-NEXT: [[ADD_PTR87:%.*]] = getelementptr inbounds i8, ptr [[ARRAYDECAY83]], i64 [[IDX_EXT86]] +// CHECK-NEXT: [[TMP36:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[F78]], ptr [[TMP36]], align 8 +// CHECK-NEXT: [[TMP37:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[ADD_PTR87]], ptr [[TMP37]], align 8 +// CHECK-NEXT: [[TMP38:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[F78]], ptr [[TMP38]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR88:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB89:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR88]], align 8 +// CHECK-NEXT: [[TMP39:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[WIDE_PTR_UB89]], ptr [[TMP39]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR90:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR91:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR90]], align 8 +// CHECK-NEXT: [[TMP40:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[ARRAYDECAY80]], ptr [[TMP40]], align 8 +// CHECK-NEXT: [[TMP41:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR91]], ptr [[TMP41]], align 8 +// CHECK-NEXT: [[TMP42:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[ARRAYDECAY80]], ptr [[TMP42]], align 8 +// CHECK-NEXT: [[TMP43:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 0 +// CHECK-NEXT: [[TMP44:%.*]] = load ptr, ptr [[TMP43]], align 8 +// CHECK-NEXT: [[BOUND_PTR_ARITH:%.*]] = getelementptr i8, ptr [[TMP44]], i64 0 +// CHECK-NEXT: [[TMP45:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[BOUND_PTR_ARITH]], ptr [[TMP45]], align 8 +// CHECK-NEXT: [[TMP46:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 1 +// CHECK-NEXT: [[TMP47:%.*]] = load ptr, ptr [[TMP46]], align 8 +// CHECK-NEXT: [[TMP48:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[TMP47]], ptr [[TMP48]], align 8 +// CHECK-NEXT: [[TMP49:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 2 +// CHECK-NEXT: [[TMP50:%.*]] = load ptr, ptr [[TMP49]], align 8 +// CHECK-NEXT: [[TMP51:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[TMP50]], ptr [[TMP51]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR92:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR93:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR92]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR94:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB95:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR94]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR96:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB97:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR96]], align 8 +// CHECK-NEXT: [[TMP52:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR93]], ptr [[TMP52]], align 8 +// CHECK-NEXT: [[TMP53:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[WIDE_PTR_UB95]], ptr [[TMP53]], align 8 +// CHECK-NEXT: [[TMP54:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[WIDE_PTR_LB97]], ptr [[TMP54]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR98:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR99:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR98]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR100:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB101:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR100]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR102:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB103:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR102]], align 8 +// CHECK-NEXT: call void @use(ptr noundef [[WIDE_PTR_PTR99]]) +// CHECK-NEXT: ret void +// +void process_frame(char *__counted_by(frame_size) frame, unsigned frame_size) { + outer_flex_t *of = (outer_flex_t *) frame; + use(&of->f); + use(of->f.arr); + use(&of->f.arr[0]); +} +//. +// CHECK: [[META2]] = !{!"bounds-safety-check-ptr-lt-upper-bound"} +// CHECK: [[PROF3]] = !{!"branch_weights", i32 1048575, i32 1} +// CHECK: [[META4]] = !{!"bounds-safety-check-ptr-ge-lower-bound"} +//. diff --git a/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member.c b/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member.c new file mode 100644 index 0000000000000..e4c2f087c761b --- /dev/null +++ b/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member.c @@ -0,0 +1,269 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 + +// RUN: %clang_cc1 -O0 -fbounds-safety -triple arm64e-apple-ios -emit-llvm %s -o - | FileCheck %s + +#include +typedef struct { + int count; + char arr[__counted_by(count)]; +} flex_t; + +typedef struct { + flex_t f; +} outer_flex_t; + +void use(void *__unsafe_indexable); + +// CHECK-LABEL: define void @process_frame( +// CHECK-SAME: ptr noundef [[FRAME:%.*]], i32 noundef [[FRAME_SIZE:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[FRAME_ADDR:%.*]] = alloca ptr, align 8 +// CHECK-NEXT: [[FRAME_SIZE_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[OF:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 +// CHECK-NEXT: [[AGG_TEMP:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 +// CHECK-NEXT: [[AGG_TEMP1:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.1", align 8 +// CHECK-NEXT: [[AGG_TEMP2:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.2", align 8 +// CHECK-NEXT: [[AGG_TEMP3:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 +// CHECK-NEXT: [[AGG_TEMP26:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.1", align 8 +// CHECK-NEXT: [[AGG_TEMP27:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 +// CHECK-NEXT: [[AGG_TEMP28:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 +// CHECK-NEXT: [[AGG_TEMP42:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.2", align 8 +// CHECK-NEXT: [[AGG_TEMP64:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.1", align 8 +// CHECK-NEXT: [[AGG_TEMP65:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 +// CHECK-NEXT: [[TMP:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 +// CHECK-NEXT: [[AGG_TEMP66:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 +// CHECK-NEXT: [[AGG_TEMP80:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.2", align 8 +// CHECK-NEXT: store ptr [[FRAME]], ptr [[FRAME_ADDR]], align 8 +// CHECK-NEXT: store i32 [[FRAME_SIZE]], ptr [[FRAME_SIZE_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[FRAME_ADDR]], align 8 +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[FRAME_SIZE_ADDR]], align 4 +// CHECK-NEXT: [[IDX_EXT:%.*]] = zext i32 [[TMP1]] to i64 +// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP0]], i64 [[IDX_EXT]] +// CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[TMP0]], ptr [[TMP2]], align 8 +// CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[ADD_PTR]], ptr [[TMP3]], align 8 +// CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[TMP0]], ptr [[TMP4]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR]], align 8 +// CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR]], ptr [[TMP5]], align 8 +// CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[WIDE_PTR_UB]], ptr [[TMP6]], align 8 +// CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[WIDE_PTR_LB]], ptr [[TMP7]], align 8 +// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP3]], ptr align 8 [[OF]], i64 24, i1 false) +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR4:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR5:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR4]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR6:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB7:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR6]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR8:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB9:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR8]], align 8 +// CHECK-NEXT: [[TMP8:%.*]] = getelementptr [[STRUCT_OUTER_FLEX_T:%.*]], ptr [[WIDE_PTR_PTR5]], i64 1 +// CHECK-NEXT: [[TMP9:%.*]] = icmp ule ptr [[TMP8]], [[WIDE_PTR_UB7]], !annotation [[META2:![0-9]+]] +// CHECK-NEXT: br i1 [[TMP9]], label %[[CONT:.*]], label %[[TRAP:.*]], !prof [[PROF3:![0-9]+]], !annotation [[META2]] +// CHECK: [[TRAP]]: +// CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4:[0-9]+]], !annotation [[META2]] +// CHECK-NEXT: unreachable, !annotation [[META2]] +// CHECK: [[CONT]]: +// CHECK-NEXT: [[TMP10:%.*]] = icmp ule ptr [[WIDE_PTR_LB9]], [[WIDE_PTR_PTR5]], !annotation [[META4:![0-9]+]] +// CHECK-NEXT: br i1 [[TMP10]], label %[[CONT11:.*]], label %[[TRAP10:.*]], !prof [[PROF3]], !annotation [[META4]] +// CHECK: [[TRAP10]]: +// CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META4]] +// CHECK-NEXT: unreachable, !annotation [[META4]] +// CHECK: [[CONT11]]: +// CHECK-NEXT: [[F:%.*]] = getelementptr inbounds nuw [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR5]], i32 0, i32 0 +// CHECK-NEXT: [[ARR:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T:%.*]], ptr [[F]], i32 0, i32 1 +// CHECK-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR]], i64 0, i64 0 +// CHECK-NEXT: [[COUNT:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F]], i32 0, i32 0 +// CHECK-NEXT: [[TMP11:%.*]] = load i32, ptr [[COUNT]], align 4 +// CHECK-NEXT: [[IDX_EXT12:%.*]] = sext i32 [[TMP11]] to i64 +// CHECK-NEXT: [[ADD_PTR13:%.*]] = getelementptr inbounds i8, ptr [[ARRAYDECAY]], i64 [[IDX_EXT12]] +// CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[F]], ptr [[TMP12]], align 8 +// CHECK-NEXT: [[TMP13:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[ADD_PTR13]], ptr [[TMP13]], align 8 +// CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[F]], ptr [[TMP14]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR14:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR15:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR14]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR16:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB17:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR16]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR18:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB19:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR18]], align 8 +// CHECK-NEXT: [[TMP15:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR15]], ptr [[TMP15]], align 8 +// CHECK-NEXT: [[TMP16:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[WIDE_PTR_UB17]], ptr [[TMP16]], align 8 +// CHECK-NEXT: [[TMP17:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[WIDE_PTR_LB19]], ptr [[TMP17]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR20:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR21:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR20]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR22:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB23:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR22]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR24:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB25:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR24]], align 8 +// CHECK-NEXT: call void @use(ptr noundef [[WIDE_PTR_PTR21]]) +// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP28]], ptr align 8 [[OF]], i64 24, i1 false) +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR29:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR30:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR29]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR31:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB32:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR31]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR33:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB34:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR33]], align 8 +// CHECK-NEXT: [[TMP18:%.*]] = getelementptr [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR30]], i64 1 +// CHECK-NEXT: [[TMP19:%.*]] = icmp ule ptr [[TMP18]], [[WIDE_PTR_UB32]], !annotation [[META2]] +// CHECK-NEXT: br i1 [[TMP19]], label %[[CONT36:.*]], label %[[TRAP35:.*]], !prof [[PROF3]], !annotation [[META2]] +// CHECK: [[TRAP35]]: +// CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META2]] +// CHECK-NEXT: unreachable, !annotation [[META2]] +// CHECK: [[CONT36]]: +// CHECK-NEXT: [[TMP20:%.*]] = icmp ule ptr [[WIDE_PTR_LB34]], [[WIDE_PTR_PTR30]], !annotation [[META4]] +// CHECK-NEXT: br i1 [[TMP20]], label %[[CONT38:.*]], label %[[TRAP37:.*]], !prof [[PROF3]], !annotation [[META4]] +// CHECK: [[TRAP37]]: +// CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META4]] +// CHECK-NEXT: unreachable, !annotation [[META4]] +// CHECK: [[CONT38]]: +// CHECK-NEXT: [[F39:%.*]] = getelementptr inbounds nuw [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR30]], i32 0, i32 0 +// CHECK-NEXT: [[ARR40:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 1 +// CHECK-NEXT: [[ARRAYDECAY41:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR40]], i64 0, i64 0 +// CHECK-NEXT: [[ARR43:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 1 +// CHECK-NEXT: [[ARRAYDECAY44:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR43]], i64 0, i64 0 +// CHECK-NEXT: [[COUNT45:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 0 +// CHECK-NEXT: [[TMP21:%.*]] = load i32, ptr [[COUNT45]], align 4 +// CHECK-NEXT: [[IDX_EXT46:%.*]] = sext i32 [[TMP21]] to i64 +// CHECK-NEXT: [[ADD_PTR47:%.*]] = getelementptr inbounds i8, ptr [[ARRAYDECAY44]], i64 [[IDX_EXT46]] +// CHECK-NEXT: [[TMP22:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[F39]], ptr [[TMP22]], align 8 +// CHECK-NEXT: [[TMP23:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[ADD_PTR47]], ptr [[TMP23]], align 8 +// CHECK-NEXT: [[TMP24:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[F39]], ptr [[TMP24]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR48:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB49:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR48]], align 8 +// CHECK-NEXT: [[TMP25:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[WIDE_PTR_UB49]], ptr [[TMP25]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR50:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR51:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR50]], align 8 +// CHECK-NEXT: [[TMP26:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[ARRAYDECAY41]], ptr [[TMP26]], align 8 +// CHECK-NEXT: [[TMP27:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR51]], ptr [[TMP27]], align 8 +// CHECK-NEXT: [[TMP28:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[ARRAYDECAY41]], ptr [[TMP28]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR52:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR53:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR52]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR54:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB55:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR54]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR56:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB57:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR56]], align 8 +// CHECK-NEXT: [[TMP29:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR53]], ptr [[TMP29]], align 8 +// CHECK-NEXT: [[TMP30:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[WIDE_PTR_UB55]], ptr [[TMP30]], align 8 +// CHECK-NEXT: [[TMP31:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[WIDE_PTR_LB57]], ptr [[TMP31]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR58:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR59:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR58]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR60:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB61:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR60]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR62:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB63:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR62]], align 8 +// CHECK-NEXT: call void @use(ptr noundef [[WIDE_PTR_PTR59]]) +// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP66]], ptr align 8 [[OF]], i64 24, i1 false) +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR67:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP66]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR68:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR67]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR69:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP66]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB70:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR69]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR71:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP66]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB72:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR71]], align 8 +// CHECK-NEXT: [[TMP32:%.*]] = getelementptr [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR68]], i64 1 +// CHECK-NEXT: [[TMP33:%.*]] = icmp ule ptr [[TMP32]], [[WIDE_PTR_UB70]], !annotation [[META2]] +// CHECK-NEXT: br i1 [[TMP33]], label %[[CONT74:.*]], label %[[TRAP73:.*]], !prof [[PROF3]], !annotation [[META2]] +// CHECK: [[TRAP73]]: +// CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META2]] +// CHECK-NEXT: unreachable, !annotation [[META2]] +// CHECK: [[CONT74]]: +// CHECK-NEXT: [[TMP34:%.*]] = icmp ule ptr [[WIDE_PTR_LB72]], [[WIDE_PTR_PTR68]], !annotation [[META4]] +// CHECK-NEXT: br i1 [[TMP34]], label %[[CONT76:.*]], label %[[TRAP75:.*]], !prof [[PROF3]], !annotation [[META4]] +// CHECK: [[TRAP75]]: +// CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META4]] +// CHECK-NEXT: unreachable, !annotation [[META4]] +// CHECK: [[CONT76]]: +// CHECK-NEXT: [[F77:%.*]] = getelementptr inbounds nuw [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR68]], i32 0, i32 0 +// CHECK-NEXT: [[ARR78:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F77]], i32 0, i32 1 +// CHECK-NEXT: [[ARRAYDECAY79:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR78]], i64 0, i64 0 +// CHECK-NEXT: [[ARR81:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F77]], i32 0, i32 1 +// CHECK-NEXT: [[ARRAYDECAY82:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR81]], i64 0, i64 0 +// CHECK-NEXT: [[COUNT83:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F77]], i32 0, i32 0 +// CHECK-NEXT: [[TMP35:%.*]] = load i32, ptr [[COUNT83]], align 4 +// CHECK-NEXT: [[IDX_EXT84:%.*]] = sext i32 [[TMP35]] to i64 +// CHECK-NEXT: [[ADD_PTR85:%.*]] = getelementptr inbounds i8, ptr [[ARRAYDECAY82]], i64 [[IDX_EXT84]] +// CHECK-NEXT: [[TMP36:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[F77]], ptr [[TMP36]], align 8 +// CHECK-NEXT: [[TMP37:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[ADD_PTR85]], ptr [[TMP37]], align 8 +// CHECK-NEXT: [[TMP38:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[F77]], ptr [[TMP38]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR86:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB87:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR86]], align 8 +// CHECK-NEXT: [[TMP39:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[WIDE_PTR_UB87]], ptr [[TMP39]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR88:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR89:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR88]], align 8 +// CHECK-NEXT: [[TMP40:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[ARRAYDECAY79]], ptr [[TMP40]], align 8 +// CHECK-NEXT: [[TMP41:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR89]], ptr [[TMP41]], align 8 +// CHECK-NEXT: [[TMP42:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[ARRAYDECAY79]], ptr [[TMP42]], align 8 +// CHECK-NEXT: [[TMP43:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 0 +// CHECK-NEXT: [[TMP44:%.*]] = load ptr, ptr [[TMP43]], align 8 +// CHECK-NEXT: [[BOUND_PTR_ARITH:%.*]] = getelementptr i8, ptr [[TMP44]], i64 0 +// CHECK-NEXT: [[TMP45:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[BOUND_PTR_ARITH]], ptr [[TMP45]], align 8 +// CHECK-NEXT: [[TMP46:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 1 +// CHECK-NEXT: [[TMP47:%.*]] = load ptr, ptr [[TMP46]], align 8 +// CHECK-NEXT: [[TMP48:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[TMP47]], ptr [[TMP48]], align 8 +// CHECK-NEXT: [[TMP49:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 2 +// CHECK-NEXT: [[TMP50:%.*]] = load ptr, ptr [[TMP49]], align 8 +// CHECK-NEXT: [[TMP51:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[TMP50]], ptr [[TMP51]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR90:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR91:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR90]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR92:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB93:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR92]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR94:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB95:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR94]], align 8 +// CHECK-NEXT: [[TMP52:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 0 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR91]], ptr [[TMP52]], align 8 +// CHECK-NEXT: [[TMP53:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 1 +// CHECK-NEXT: store ptr [[WIDE_PTR_UB93]], ptr [[TMP53]], align 8 +// CHECK-NEXT: [[TMP54:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 2 +// CHECK-NEXT: store ptr [[WIDE_PTR_LB95]], ptr [[TMP54]], align 8 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR96:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR97:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR96]], align 8 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR98:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB99:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR98]], align 8 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR100:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB101:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR100]], align 8 +// CHECK-NEXT: call void @use(ptr noundef [[WIDE_PTR_PTR97]]) +// CHECK-NEXT: ret void +// +void process_frame(char *__counted_by(frame_size) frame, unsigned frame_size) { + outer_flex_t *of = (outer_flex_t *) frame; + use(&of->f); + use(of->f.arr); + use(&of->f.arr[0]); +} +//. +// CHECK: [[META2]] = !{!"bounds-safety-check-ptr-lt-upper-bound"} +// CHECK: [[PROF3]] = !{!"branch_weights", i32 1048575, i32 1} +// CHECK: [[META4]] = !{!"bounds-safety-check-ptr-ge-lower-bound"} +//. From c38d840dda8ac5580e8d488952b143612249585d Mon Sep 17 00:00:00 2001 From: Yeoul Na Date: Wed, 9 Jul 2025 12:26:31 -0700 Subject: [PATCH 2/4] [BoundsSafety][NFC] Don't emit wide pointer indexing in argument passing in order to avoid non-determinism The execution order of arguments is unspecified in C++. Directly passing calls that emit code as arguments caused non-deterministic order in the generated instructions and test failures in different platforms. (cherry picked from commit 0a18d9a09a79cbc5e349aeb4379628d1ea079482) --- clang/lib/CodeGen/CGExprAgg.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index 4def8df7e7933..39e0b6dfef9fb 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -436,13 +436,13 @@ void AggExprEmitter::EmitWidePointerBitCast(CastExpr *E) { RValue SrcRV = CGF.EmitAnyExpr(E->getSubExpr()); assert(SrcRV.isAggregate()); Address SrcAddr = SrcRV.getAggregateAddress(); - EmitWidePointerToDest(E->getType(), - CGF.GetWidePointerElement(SrcAddr, WPIndex::Pointer), - CGF.GetWidePointerElement(SrcAddr, WPIndex::Upper), - E->getType()->isBidiIndexablePointerType() + llvm::Value *Ptr = CGF.GetWidePointerElement(SrcAddr, WPIndex::Pointer); + llvm::Value *Upper = CGF.GetWidePointerElement(SrcAddr, WPIndex::Upper); + llvm::Value *Lower = E->getType()->isBidiIndexablePointerType() ? CGF.GetWidePointerElement(SrcAddr, WPIndex::Lower) - : nullptr, - ElemBitCast); + : nullptr; + + EmitWidePointerToDest(E->getType(), Ptr, Upper, Lower, ElemBitCast); } void AggExprEmitter::EmitWidePointer(LValue DestLV, llvm::Value *Ptr, From 4a58b2482f280ad9c4463d1fc4b80aec2468a2e3 Mon Sep 17 00:00:00 2001 From: Yeoul Na Date: Fri, 11 Jul 2025 10:30:52 -0700 Subject: [PATCH 3/4] [BoundsSafety][NFC] Adjust BoundsSafety-legacy codegen tests (cherry picked from commit 45afadf9feb3bd66ab43293262cb5a9537aef528) --- .../CodeGen/constant-eval-count-static-init.c | 14 +- .../count-attr-fields-assign-2-oob2.c | 54 ++++--- .../dep-count-init-list-basic-O2.c | 4 +- .../flexible-array-member-promotion-deref.c | 134 +++++++++--------- .../CodeGen/multiple-dependees.c | 20 ++- ...exible-array-member-checks-code-coverage.c | 16 +-- 6 files changed, 113 insertions(+), 129 deletions(-) diff --git a/clang/test/BoundsSafety-legacy-checks/CodeGen/constant-eval-count-static-init.c b/clang/test/BoundsSafety-legacy-checks/CodeGen/constant-eval-count-static-init.c index 37c9d0e7ea834..d47a75921d07f 100644 --- a/clang/test/BoundsSafety-legacy-checks/CodeGen/constant-eval-count-static-init.c +++ b/clang/test/BoundsSafety-legacy-checks/CodeGen/constant-eval-count-static-init.c @@ -16,13 +16,9 @@ const Item oidRsa = { _oidRsa, sizeof(_oidRsa)}; // CHECK-NEXT: entry: // CHECK-NEXT: [[RETVAL:%.*]] = alloca i32, align 4 // CHECK-NEXT: [[AGG_TEMP:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-NEXT: [[AGG_TEMP1:%.*]] = alloca [[STRUCT_ITEM:%.*]], align 8 // CHECK-NEXT: store i32 0, ptr [[RETVAL]], align 4 -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP1]], ptr align 8 @oidRsa, i64 16, i1 false) -// CHECK-NEXT: [[LENGTH:%.*]] = getelementptr inbounds [[STRUCT_ITEM]], ptr [[AGG_TEMP1]], i32 0, i32 1 -// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[LENGTH]], align 8 -// CHECK-NEXT: [[DATA:%.*]] = getelementptr inbounds [[STRUCT_ITEM]], ptr [[AGG_TEMP1]], i32 0, i32 0 -// CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[DATA]], align 8 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr getelementptr inbounds ([[STRUCT_ITEM:%.*]], ptr @oidRsa, i32 0, i32 1), align 8 +// CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr @oidRsa, align 8 // CHECK-NEXT: [[IDX_EXT:%.*]] = sext i32 [[TMP0]] to i64 // CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[TMP1]], i64 [[IDX_EXT]] // CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP]], i32 0, i32 0 @@ -45,11 +41,11 @@ const Item oidRsa = { _oidRsa, sizeof(_oidRsa)}; // CHECK-NEXT: unreachable // CHECK: cont: // CHECK-NEXT: [[TMP7:%.*]] = icmp uge ptr [[TMP5]], [[WIDE_PTR_LB]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP7]], label [[CONT3:%.*]], label [[TRAP2:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap2: +// CHECK-NEXT: br i1 [[TMP7]], label %[[CONT3:.*]], label %[[TRAP2:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP2]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable -// CHECK: cont3: +// CHECK: [[CONT3]]: // CHECK-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP5]], align 4 // CHECK-NEXT: ret i32 [[TMP8]] // diff --git a/clang/test/BoundsSafety-legacy-checks/CodeGen/count-dependent-assignment-checks/count-attr-fields-assign-2-oob2.c b/clang/test/BoundsSafety-legacy-checks/CodeGen/count-dependent-assignment-checks/count-attr-fields-assign-2-oob2.c index 79dad5d2435a7..5f18134eb1190 100644 --- a/clang/test/BoundsSafety-legacy-checks/CodeGen/count-dependent-assignment-checks/count-attr-fields-assign-2-oob2.c +++ b/clang/test/BoundsSafety-legacy-checks/CodeGen/count-dependent-assignment-checks/count-attr-fields-assign-2-oob2.c @@ -26,11 +26,8 @@ struct S { // CHECK-O0-NEXT: [[AGG_TEMP33:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-O0-NEXT: [[I:%.*]] = alloca i32, align 4 // CHECK-O0-NEXT: [[AGG_TEMP42:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-O0-NEXT: [[AGG_TEMP43:%.*]] = alloca [[STRUCT_S]], align 8 // CHECK-O0-NEXT: [[AGG_TEMP56:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-O0-NEXT: [[AGG_TEMP57:%.*]] = alloca [[STRUCT_S]], align 8 // CHECK-O0-NEXT: [[AGG_TEMP73:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-O0-NEXT: [[AGG_TEMP74:%.*]] = alloca [[STRUCT_S]], align 8 // CHECK-O0-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [10 x i32], ptr [[ARR]], i64 0, i64 0 // CHECK-O0-NEXT: [[UPPER:%.*]] = getelementptr inbounds i32, ptr [[ARRAYDECAY]], i64 10 // CHECK-O0-NEXT: [[TMP0:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[TMP]], i32 0, i32 0 @@ -146,10 +143,9 @@ struct S { // CHECK-O0-NEXT: br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]] // CHECK-O0: for.body: // CHECK-O0-NEXT: [[TMP23:%.*]] = load i32, ptr [[I]], align 4 -// CHECK-O0-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP43]], ptr align 8 [[S]], i64 24, i1 false) -// CHECK-O0-NEXT: [[L44:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP43]], i32 0, i32 2 +// CHECK-O0-NEXT: [[L44:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 2 // CHECK-O0-NEXT: [[TMP24:%.*]] = load i32, ptr [[L44]], align 8 -// CHECK-O0-NEXT: [[BP45:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP43]], i32 0, i32 0 +// CHECK-O0-NEXT: [[BP45:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 0 // CHECK-O0-NEXT: [[TMP25:%.*]] = load ptr, ptr [[BP45]], align 8 // CHECK-O0-NEXT: [[IDX_EXT:%.*]] = sext i32 [[TMP24]] to i64 // CHECK-O0-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr [[TMP25]], i64 [[IDX_EXT]] @@ -169,17 +165,17 @@ struct S { // CHECK-O0-NEXT: [[WIDE_PTR_LB_ADDR50:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP42]], i32 0, i32 2 // CHECK-O0-NEXT: [[WIDE_PTR_LB51:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR50]], align 8 // CHECK-O0-NEXT: [[TMP30:%.*]] = icmp ult ptr [[ARRAYIDX]], [[WIDE_PTR_UB49]], {{!annotation ![0-9]+}} -// CHECK-O0-NEXT: br i1 [[TMP30]], label [[CONT53:%.*]], label [[TRAP52:%.*]], {{!annotation ![0-9]+}} -// CHECK-O0: trap52: +// CHECK-O0-NEXT: br i1 [[TMP30]], label %[[CONT53:.*]], label %[[TRAP52:.*]], {{!annotation ![0-9]+}} +// CHECK-O0: [[TRAP52]]: // CHECK-O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-O0-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK-O0: cont53: +// CHECK-O0: [[CONT53]]: // CHECK-O0-NEXT: [[TMP31:%.*]] = icmp uge ptr [[ARRAYIDX]], [[WIDE_PTR_LB51]], {{!annotation ![0-9]+}} -// CHECK-O0-NEXT: br i1 [[TMP31]], label [[CONT55:%.*]], label [[TRAP54:%.*]], {{!annotation ![0-9]+}} -// CHECK-O0: trap54: +// CHECK-O0-NEXT: br i1 [[TMP31]], label %[[CONT55:.*]], label %[[TRAP54:.*]], {{!annotation ![0-9]+}} +// CHECK-O0: [[TRAP54]]: // CHECK-O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-O0-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK-O0: cont55: +// CHECK-O0: [[CONT55]]: // CHECK-O0-NEXT: store i32 [[TMP23]], ptr [[ARRAYIDX]], align 4 // CHECK-O0-NEXT: br label [[FOR_INC:%.*]] // CHECK-O0: for.inc: @@ -188,10 +184,9 @@ struct S { // CHECK-O0-NEXT: store i32 [[INC]], ptr [[I]], align 4 // CHECK-O0-NEXT: br label [[FOR_COND]], !llvm.loop [[LOOP5:![0-9]+]] // CHECK-O0: for.end: -// CHECK-O0-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP57]], ptr align 8 [[S]], i64 24, i1 false) -// CHECK-O0-NEXT: [[L58:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP57]], i32 0, i32 2 +// CHECK-O0-NEXT: [[L58:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 2 // CHECK-O0-NEXT: [[TMP33:%.*]] = load i32, ptr [[L58]], align 8 -// CHECK-O0-NEXT: [[BP259:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP57]], i32 0, i32 1 +// CHECK-O0-NEXT: [[BP259:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 1 // CHECK-O0-NEXT: [[TMP34:%.*]] = load ptr, ptr [[BP259]], align 8 // CHECK-O0-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP33]], 1 // CHECK-O0-NEXT: [[IDX_EXT60:%.*]] = sext i32 [[ADD]] to i64 @@ -210,22 +205,21 @@ struct S { // CHECK-O0-NEXT: [[WIDE_PTR_LB_ADDR67:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP56]], i32 0, i32 2 // CHECK-O0-NEXT: [[WIDE_PTR_LB68:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR67]], align 8 // CHECK-O0-NEXT: [[TMP38:%.*]] = icmp ult ptr [[ARRAYIDX64]], [[WIDE_PTR_UB66]], {{!annotation ![0-9]+}} -// CHECK-O0-NEXT: br i1 [[TMP38]], label [[CONT70:%.*]], label [[TRAP69:%.*]], {{!annotation ![0-9]+}} -// CHECK-O0: trap69: +// CHECK-O0-NEXT: br i1 [[TMP38]], label %[[CONT70:.*]], label %[[TRAP69:.*]], {{!annotation ![0-9]+}} +// CHECK-O0: [[TRAP69]]: // CHECK-O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-O0-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK-O0: cont70: +// CHECK-O0: [[CONT70]]: // CHECK-O0-NEXT: [[TMP39:%.*]] = icmp uge ptr [[ARRAYIDX64]], [[WIDE_PTR_LB68]], {{!annotation ![0-9]+}} -// CHECK-O0-NEXT: br i1 [[TMP39]], label [[CONT72:%.*]], label [[TRAP71:%.*]], {{!annotation ![0-9]+}} -// CHECK-O0: trap71: +// CHECK-O0-NEXT: br i1 [[TMP39]], label %[[CONT72:.*]], label %[[TRAP71:.*]], {{!annotation ![0-9]+}} +// CHECK-O0: [[TRAP71]]: // CHECK-O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-O0-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK-O0: cont72: +// CHECK-O0: [[CONT72]]: // CHECK-O0-NEXT: [[TMP40:%.*]] = load i32, ptr [[ARRAYIDX64]], align 4 -// CHECK-O0-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP74]], ptr align 8 [[S]], i64 24, i1 false) -// CHECK-O0-NEXT: [[L75:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP74]], i32 0, i32 2 +// CHECK-O0-NEXT: [[L75:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 2 // CHECK-O0-NEXT: [[TMP41:%.*]] = load i32, ptr [[L75]], align 8 -// CHECK-O0-NEXT: [[BP76:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP74]], i32 0, i32 0 +// CHECK-O0-NEXT: [[BP76:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 0 // CHECK-O0-NEXT: [[TMP42:%.*]] = load ptr, ptr [[BP76]], align 8 // CHECK-O0-NEXT: [[IDX_EXT77:%.*]] = sext i32 [[TMP41]] to i64 // CHECK-O0-NEXT: [[ADD_PTR78:%.*]] = getelementptr inbounds i32, ptr [[TMP42]], i64 [[IDX_EXT77]] @@ -243,17 +237,17 @@ struct S { // CHECK-O0-NEXT: [[WIDE_PTR_LB_ADDR84:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP73]], i32 0, i32 2 // CHECK-O0-NEXT: [[WIDE_PTR_LB85:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR84]], align 8 // CHECK-O0-NEXT: [[TMP46:%.*]] = icmp ult ptr [[ARRAYIDX81]], [[WIDE_PTR_UB83]], {{!annotation ![0-9]+}} -// CHECK-O0-NEXT: br i1 [[TMP46]], label [[CONT87:%.*]], label [[TRAP86:%.*]], {{!annotation ![0-9]+}} -// CHECK-O0: trap86: +// CHECK-O0-NEXT: br i1 [[TMP46]], label %[[CONT87:.*]], label %[[TRAP86:.*]], {{!annotation ![0-9]+}} +// CHECK-O0: [[TRAP86]]: // CHECK-O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-O0-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK-O0: cont87: +// CHECK-O0: [[CONT87]]: // CHECK-O0-NEXT: [[TMP47:%.*]] = icmp uge ptr [[ARRAYIDX81]], [[WIDE_PTR_LB85]], {{!annotation ![0-9]+}} -// CHECK-O0-NEXT: br i1 [[TMP47]], label [[CONT89:%.*]], label [[TRAP88:%.*]], {{!annotation ![0-9]+}} -// CHECK-O0: trap88: +// CHECK-O0-NEXT: br i1 [[TMP47]], label %[[CONT89:.*]], label %[[TRAP88:.*]], {{!annotation ![0-9]+}} +// CHECK-O0: [[TRAP88]]: // CHECK-O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-O0-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK-O0: cont89: +// CHECK-O0: [[CONT89]]: // CHECK-O0-NEXT: [[TMP48:%.*]] = load i32, ptr [[ARRAYIDX81]], align 4 // CHECK-O0-NEXT: [[ADD90:%.*]] = add nsw i32 [[TMP40]], [[TMP48]] // CHECK-O0-NEXT: ret i32 [[ADD90]] diff --git a/clang/test/BoundsSafety-legacy-checks/CodeGen/count-dependent-assignment-checks/dep-count-init-list-basic-O2.c b/clang/test/BoundsSafety-legacy-checks/CodeGen/count-dependent-assignment-checks/dep-count-init-list-basic-O2.c index 7d8d0f0d587e0..0f343d706eee6 100644 --- a/clang/test/BoundsSafety-legacy-checks/CodeGen/count-dependent-assignment-checks/dep-count-init-list-basic-O2.c +++ b/clang/test/BoundsSafety-legacy-checks/CodeGen/count-dependent-assignment-checks/dep-count-init-list-basic-O2.c @@ -102,11 +102,11 @@ void TestAccessFail() { // CHECK-NEXT: [[TMP1:%.*]] = icmp ult ptr [[TMP0]], [[UPPER]], {{!annotation ![0-9]+}} // CHECK-NEXT: [[TMP2:%.*]] = icmp uge ptr [[TMP0]], [[ARR]], {{!annotation ![0-9]+}} // CHECK-NEXT: [[OR_COND:%.*]] = and i1 [[TMP1]], [[TMP2]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[OR_COND]], label [[CONT47:%.*]], label [[TRAP:%.*]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[OR_COND]], label %[[CONT47:.*]], label [[TRAP:%.*]], {{!annotation ![0-9]+}} // CHECK: trap: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR6]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont47: +// CHECK: [[CONT47]]: // CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 36, ptr nonnull [[ARR]]) #[[ATTR7]] // CHECK-NEXT: ret void // diff --git a/clang/test/BoundsSafety-legacy-checks/CodeGen/flexible-array-member-promotion-deref.c b/clang/test/BoundsSafety-legacy-checks/CodeGen/flexible-array-member-promotion-deref.c index b389716db69a0..7b1474070ecd7 100644 --- a/clang/test/BoundsSafety-legacy-checks/CodeGen/flexible-array-member-promotion-deref.c +++ b/clang/test/BoundsSafety-legacy-checks/CodeGen/flexible-array-member-promotion-deref.c @@ -35,7 +35,7 @@ flex_t g_flex = {2, {1, 2}}; // CHECK-NEXT: [[WIDE_PTR_LB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP2]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR]], align 8 // CHECK-NEXT: [[FLEX_BASE_NULL_CHECK:%.*]] = icmp ne ptr [[WIDE_PTR_PTR]], null, {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[FLEX_BASE_NULL_CHECK]], label [[FLEX_BASE_NONNULL:%.*]], label [[CONT32:%.*]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[FLEX_BASE_NULL_CHECK]], label [[FLEX_BASE_NONNULL:%.*]], label %[[CONT32:.*]], {{!annotation ![0-9]+}} // CHECK: flex.base.nonnull: // CHECK-NEXT: [[TMP4:%.*]] = getelementptr [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR]], i64 1 // CHECK-NEXT: [[TMP5:%.*]] = icmp ule ptr [[WIDE_PTR_PTR]], [[TMP4]], {{!annotation ![0-9]+}} @@ -53,17 +53,17 @@ flex_t g_flex = {2, {1, 2}}; // CHECK-NEXT: [[WIDE_PTR_LB9:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR8]], align 8 // CHECK-NEXT: [[TMP6:%.*]] = getelementptr [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR5]], i64 1 // CHECK-NEXT: [[TMP7:%.*]] = icmp ule ptr [[TMP6]], [[WIDE_PTR_UB7]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP7]], label [[CONT11:%.*]], label [[TRAP10:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap10: +// CHECK-NEXT: br i1 [[TMP7]], label %[[CONT11:.*]], label %[[TRAP10:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP10]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable -// CHECK: cont11: +// CHECK: [[CONT11]]: // CHECK-NEXT: [[TMP8:%.*]] = icmp ule ptr [[WIDE_PTR_LB9]], [[WIDE_PTR_PTR5]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP8]], label [[CONT13:%.*]], label [[TRAP12:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap12: +// CHECK-NEXT: br i1 [[TMP8]], label %[[CONT13:.*]], label %[[TRAP12:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP12]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable -// CHECK: cont13: +// CHECK: [[CONT13]]: // CHECK-NEXT: [[ELEMS:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR5]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [0 x i32], ptr [[ELEMS]], i64 0, i64 0 // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP14]], ptr align 8 [[AGG_TEMP1]], i64 24, i1 false) @@ -75,48 +75,48 @@ flex_t g_flex = {2, {1, 2}}; // CHECK-NEXT: [[WIDE_PTR_LB20:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR19]], align 8 // CHECK-NEXT: [[TMP9:%.*]] = getelementptr [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR16]], i64 1 // CHECK-NEXT: [[TMP10:%.*]] = icmp ule ptr [[TMP9]], [[WIDE_PTR_UB18]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP10]], label [[CONT22:%.*]], label [[TRAP21:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap21: +// CHECK-NEXT: br i1 [[TMP10]], label %[[CONT22:.*]], label %[[TRAP21:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP21]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable -// CHECK: cont22: +// CHECK: [[CONT22]]: // CHECK-NEXT: [[TMP11:%.*]] = icmp ule ptr [[WIDE_PTR_LB20]], [[WIDE_PTR_PTR16]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP11]], label [[CONT24:%.*]], label [[TRAP23:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap23: +// CHECK-NEXT: br i1 [[TMP11]], label %[[CONT24:.*]], label %[[TRAP23:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP23]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable -// CHECK: cont24: +// CHECK: [[CONT24]]: // CHECK-NEXT: [[COUNT:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR16]], i32 0, i32 0 // CHECK-NEXT: [[TMP12:%.*]] = load i32, ptr [[COUNT]], align 4 // CHECK-NEXT: [[FLEX_COUNT_MINUS:%.*]] = icmp sle i32 0, [[TMP12]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[FLEX_COUNT_MINUS]], label [[CONT26:%.*]], label [[TRAP25:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap25: +// CHECK-NEXT: br i1 [[FLEX_COUNT_MINUS]], label %[[CONT26:.*]], label %[[TRAP25:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP25]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont26: +// CHECK: [[CONT26]]: // CHECK-NEXT: [[TMP13:%.*]] = icmp ule ptr [[ARRAYDECAY]], [[WIDE_PTR_UB]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP13]], label [[CONT28:%.*]], label [[TRAP27:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap27: +// CHECK-NEXT: br i1 [[TMP13]], label %[[CONT28:.*]], label %[[TRAP27:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP27]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont28: +// CHECK: [[CONT28]]: // CHECK-NEXT: [[TMP14:%.*]] = icmp uge ptr [[WIDE_PTR_PTR]], [[WIDE_PTR_LB]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP14]], label [[CONT30:%.*]], label [[TRAP29:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap29: +// CHECK-NEXT: br i1 [[TMP14]], label %[[CONT30:.*]], label %[[TRAP29:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP29]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont30: +// CHECK: [[CONT30]]: // CHECK-NEXT: [[UPPER_INTPTR:%.*]] = ptrtoint ptr [[WIDE_PTR_UB]] to i64, {{!annotation ![0-9]+}} // CHECK-NEXT: [[FAM_INTPTR:%.*]] = ptrtoint ptr [[ARRAYDECAY]] to i64, {{!annotation ![0-9]+}} // CHECK-NEXT: [[FLEX_AVAIL_COUNT:%.*]] = sub nuw i64 [[UPPER_INTPTR]], [[FAM_INTPTR]], {{!annotation ![0-9]+}} // CHECK-NEXT: [[FLEX_AVAIL_COUNT_DIV:%.*]] = sdiv exact i64 [[FLEX_AVAIL_COUNT]], 4, {{!annotation ![0-9]+}} // CHECK-NEXT: [[FLEX_COUNT_INTPTR:%.*]] = zext i32 [[TMP12]] to i64, {{!annotation ![0-9]+}} // CHECK-NEXT: [[FLEX_COUNT_CHECK:%.*]] = icmp ule i64 [[FLEX_COUNT_INTPTR]], [[FLEX_AVAIL_COUNT_DIV]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[FLEX_COUNT_CHECK]], label [[CONT32]], label [[TRAP31:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap31: +// CHECK-NEXT: br i1 [[FLEX_COUNT_CHECK]], label %[[CONT32]], label %[[TRAP31:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP31]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont32: +// CHECK: [[CONT32]]: // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP]], ptr align 8 [[AGG_TEMP1]], i64 24, i1 false) // CHECK-NEXT: [[WIDE_PTR_PTR_ADDR33:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR34:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR33]], align 8 @@ -125,20 +125,20 @@ flex_t g_flex = {2, {1, 2}}; // CHECK-NEXT: [[WIDE_PTR_LB_ADDR37:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB38:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR37]], align 8 // CHECK-NEXT: [[TMP15:%.*]] = icmp ne ptr [[WIDE_PTR_PTR34]], null, {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP15]], label [[BOUNDSCHECK_NOTNULL:%.*]], label [[CONT42:%.*]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[TMP15]], label [[BOUNDSCHECK_NOTNULL:%.*]], label %[[CONT42:.*]], {{!annotation ![0-9]+}} // CHECK: boundscheck.notnull: // CHECK-NEXT: [[TMP16:%.*]] = icmp ult ptr [[WIDE_PTR_PTR34]], [[WIDE_PTR_UB36]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP16]], label [[CONT40:%.*]], label [[TRAP39:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap39: +// CHECK-NEXT: br i1 [[TMP16]], label %[[CONT40:.*]], label %[[TRAP39:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP39]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable -// CHECK: cont40: +// CHECK: [[CONT40]]: // CHECK-NEXT: [[TMP17:%.*]] = icmp uge ptr [[WIDE_PTR_PTR34]], [[WIDE_PTR_LB38]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP17]], label [[CONT42]], label [[TRAP41:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap41: +// CHECK-NEXT: br i1 [[TMP17]], label %[[CONT42]], label %[[TRAP41:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP41]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable -// CHECK: cont42: +// CHECK: [[CONT42]]: // CHECK-NEXT: ret ptr [[WIDE_PTR_PTR34]] // flex_t *addrof_g(void) { @@ -148,7 +148,6 @@ flex_t *addrof_g(void) { // CHECK-LABEL: @addrof_deref_g( // CHECK-NEXT: entry: // CHECK-NEXT: [[AGG_TEMP:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 -// CHECK-NEXT: [[AGG_TEMP1:%.*]] = alloca [[STRUCT_FLEX_T:%.*]], align 4 // CHECK-NEXT: [[AGG_TEMP2:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP5:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @g_flex, align 4 @@ -173,26 +172,25 @@ flex_t *addrof_g(void) { // CHECK-NEXT: unreachable // CHECK: cont: // CHECK-NEXT: [[TMP5:%.*]] = icmp uge ptr [[WIDE_PTR_PTR]], [[WIDE_PTR_LB]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP5]], label [[CONT4:%.*]], label [[TRAP3:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap3: +// CHECK-NEXT: br i1 [[TMP5]], label %[[CONT4:.*]], label %[[TRAP3:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP3]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable -// CHECK: cont4: -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[AGG_TEMP1]], ptr align 4 [[WIDE_PTR_PTR]], i64 4, i1 false) -// CHECK-NEXT: [[ELEMS:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[AGG_TEMP1]], i32 0, i32 1 +// CHECK: [[CONT4]]: +// CHECK-NEXT: [[ELEMS:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [0 x i32], ptr [[ELEMS]], i64 0, i64 0 -// CHECK-NEXT: [[ELEMS6:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[AGG_TEMP1]], i32 0, i32 1 +// CHECK-NEXT: [[ELEMS6:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY7:%.*]] = getelementptr inbounds [0 x i32], ptr [[ELEMS6]], i64 0, i64 0 -// CHECK-NEXT: [[COUNT:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[AGG_TEMP1]], i32 0, i32 0 +// CHECK-NEXT: [[COUNT:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR]], i32 0, i32 0 // CHECK-NEXT: [[TMP6:%.*]] = load i32, ptr [[COUNT]], align 4 // CHECK-NEXT: [[IDX_EXT8:%.*]] = sext i32 [[TMP6]] to i64 // CHECK-NEXT: [[ADD_PTR9:%.*]] = getelementptr inbounds i32, ptr [[ARRAYDECAY7]], i64 [[IDX_EXT8]] // CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP5]], i32 0, i32 0 -// CHECK-NEXT: store ptr [[AGG_TEMP1]], ptr [[TMP7]], align 8 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR]], ptr [[TMP7]], align 8 // CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP5]], i32 0, i32 1 // CHECK-NEXT: store ptr [[ADD_PTR9]], ptr [[TMP8]], align 8 // CHECK-NEXT: [[TMP9:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP5]], i32 0, i32 2 -// CHECK-NEXT: store ptr [[AGG_TEMP1]], ptr [[TMP9]], align 8 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR]], ptr [[TMP9]], align 8 // CHECK-NEXT: [[WIDE_PTR_UB_ADDR10:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP5]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB11:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR10]], align 8 // CHECK-NEXT: [[TMP10:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP5]], i32 0, i32 0 @@ -213,17 +211,17 @@ flex_t *addrof_g(void) { // CHECK-NEXT: [[WIDE_PTR_LB_ADDR18:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB19:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR18]], align 8 // CHECK-NEXT: [[TMP15:%.*]] = icmp ult ptr [[TMP14]], [[WIDE_PTR_UB17]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP15]], label [[CONT21:%.*]], label [[TRAP20:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap20: +// CHECK-NEXT: br i1 [[TMP15]], label %[[CONT21:.*]], label %[[TRAP20:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP20]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable -// CHECK: cont21: +// CHECK: [[CONT21]]: // CHECK-NEXT: [[TMP16:%.*]] = icmp uge ptr [[TMP14]], [[WIDE_PTR_LB19]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP16]], label [[CONT23:%.*]], label [[TRAP22:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap22: +// CHECK-NEXT: br i1 [[TMP16]], label %[[CONT23:.*]], label %[[TRAP22:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP22]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable -// CHECK: cont23: +// CHECK: [[CONT23]]: // CHECK-NEXT: [[TMP17:%.*]] = load i32, ptr [[TMP14]], align 4 // CHECK-NEXT: ret i32 [[TMP17]] // @@ -241,7 +239,6 @@ int addrof_deref_g(void) { // CHECK-NEXT: [[AGG_TEMP3:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP14:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP43:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 -// CHECK-NEXT: [[AGG_TEMP44:%.*]] = alloca [[STRUCT_FLEX_T:%.*]], align 4 // CHECK-NEXT: [[AGG_TEMP45:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP62:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: store ptr [[P:%.*]], ptr [[P_INDIRECT_ADDR]], align 8 @@ -361,8 +358,8 @@ int addrof_deref_g(void) { // CHECK-NEXT: store ptr [[WIDE_PTR_PTR34]], ptr [[FLEX]], align 8 // CHECK-NEXT: [[TMP14:%.*]] = load ptr, ptr [[FLEX]], align 8 // CHECK-NEXT: [[TMP15:%.*]] = icmp ne ptr [[TMP14]], null, {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP15]], label [[BOUNDSCHECK_NOTNULL46:%.*]], label [[BOUNDSCHECK_NULL:%.*]], {{!annotation ![0-9]+}} -// CHECK: boundscheck.notnull46: +// CHECK-NEXT: br i1 [[TMP15]], label %[[BOUNDSCHECK_NOTNULL46:.*]], label [[BOUNDSCHECK_NULL:%.*]], {{!annotation ![0-9]+}} +// CHECK: [[BOUNDSCHECK_NOTNULL46]]: // CHECK-NEXT: [[ELEMS47:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[TMP14]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY48:%.*]] = getelementptr inbounds [0 x i32], ptr [[ELEMS47]], i64 0, i64 0 // CHECK-NEXT: [[COUNT49:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[TMP14]], i32 0, i32 0 @@ -392,32 +389,31 @@ int addrof_deref_g(void) { // CHECK-NEXT: [[WIDE_PTR_LB_ADDR54:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP45]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB55:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR54]], align 8 // CHECK-NEXT: [[TMP23:%.*]] = icmp ult ptr [[WIDE_PTR_PTR51]], [[WIDE_PTR_UB53]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP23]], label [[CONT57:%.*]], label [[TRAP56:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap56: +// CHECK-NEXT: br i1 [[TMP23]], label %[[CONT57:.*]], label %[[TRAP56:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP56]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable -// CHECK: cont57: +// CHECK: [[CONT57]]: // CHECK-NEXT: [[TMP24:%.*]] = icmp uge ptr [[WIDE_PTR_PTR51]], [[WIDE_PTR_LB55]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP24]], label [[CONT59:%.*]], label [[TRAP58:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap58: +// CHECK-NEXT: br i1 [[TMP24]], label %[[CONT59:.*]], label %[[TRAP58:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP58]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable -// CHECK: cont59: -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[AGG_TEMP44]], ptr align 4 [[WIDE_PTR_PTR51]], i64 4, i1 false) -// CHECK-NEXT: [[ELEMS60:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[AGG_TEMP44]], i32 0, i32 1 +// CHECK: [[CONT59]]: +// CHECK-NEXT: [[ELEMS60:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR51]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY61:%.*]] = getelementptr inbounds [0 x i32], ptr [[ELEMS60]], i64 0, i64 0 -// CHECK-NEXT: [[ELEMS63:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[AGG_TEMP44]], i32 0, i32 1 +// CHECK-NEXT: [[ELEMS63:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR51]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY64:%.*]] = getelementptr inbounds [0 x i32], ptr [[ELEMS63]], i64 0, i64 0 -// CHECK-NEXT: [[COUNT65:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[AGG_TEMP44]], i32 0, i32 0 +// CHECK-NEXT: [[COUNT65:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR51]], i32 0, i32 0 // CHECK-NEXT: [[TMP25:%.*]] = load i32, ptr [[COUNT65]], align 4 // CHECK-NEXT: [[IDX_EXT66:%.*]] = sext i32 [[TMP25]] to i64 // CHECK-NEXT: [[ADD_PTR67:%.*]] = getelementptr inbounds i32, ptr [[ARRAYDECAY64]], i64 [[IDX_EXT66]] // CHECK-NEXT: [[TMP26:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP62]], i32 0, i32 0 -// CHECK-NEXT: store ptr [[AGG_TEMP44]], ptr [[TMP26]], align 8 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR51]], ptr [[TMP26]], align 8 // CHECK-NEXT: [[TMP27:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP62]], i32 0, i32 1 // CHECK-NEXT: store ptr [[ADD_PTR67]], ptr [[TMP27]], align 8 // CHECK-NEXT: [[TMP28:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP62]], i32 0, i32 2 -// CHECK-NEXT: store ptr [[AGG_TEMP44]], ptr [[TMP28]], align 8 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR51]], ptr [[TMP28]], align 8 // CHECK-NEXT: [[WIDE_PTR_UB_ADDR68:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP62]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB69:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR68]], align 8 // CHECK-NEXT: [[TMP29:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP62]], i32 0, i32 0 @@ -438,17 +434,17 @@ int addrof_deref_g(void) { // CHECK-NEXT: [[WIDE_PTR_LB_ADDR76:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP43]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB77:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR76]], align 8 // CHECK-NEXT: [[TMP34:%.*]] = icmp ult ptr [[TMP33]], [[WIDE_PTR_UB75]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP34]], label [[CONT79:%.*]], label [[TRAP78:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap78: +// CHECK-NEXT: br i1 [[TMP34]], label %[[CONT79:.*]], label %[[TRAP78:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP78]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable -// CHECK: cont79: +// CHECK: [[CONT79]]: // CHECK-NEXT: [[TMP35:%.*]] = icmp uge ptr [[TMP33]], [[WIDE_PTR_LB77]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP35]], label [[CONT81:%.*]], label [[TRAP80:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap80: +// CHECK-NEXT: br i1 [[TMP35]], label %[[CONT81:.*]], label %[[TRAP80:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP80]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable -// CHECK: cont81: +// CHECK: [[CONT81]]: // CHECK-NEXT: store i32 10, ptr [[TMP33]], align 4 // CHECK-NEXT: ret void // diff --git a/clang/test/BoundsSafety-legacy-checks/CodeGen/multiple-dependees.c b/clang/test/BoundsSafety-legacy-checks/CodeGen/multiple-dependees.c index 4516115ecedc5..8e97bcb953b34 100644 --- a/clang/test/BoundsSafety-legacy-checks/CodeGen/multiple-dependees.c +++ b/clang/test/BoundsSafety-legacy-checks/CodeGen/multiple-dependees.c @@ -26,7 +26,6 @@ struct T { // CHECK-NEXT: [[AGG_TEMP20:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP32:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP40:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-NEXT: [[AGG_TEMP41:%.*]] = alloca [[STRUCT_T]], align 8 // CHECK-NEXT: store i32 [[IDX:%.*]], ptr [[IDX_ADDR]], align 4 // CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 16 [[ARR]], i8 0, i64 64, i1 false) // CHECK-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [16 x i32], ptr [[ARR]], i64 0, i64 0 @@ -111,12 +110,11 @@ struct T { // CHECK-NEXT: [[WIDE_PTR_LB38:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR37]], align 8 // CHECK-NEXT: [[PTR39:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[T]], i32 0, i32 2 // CHECK-NEXT: store ptr [[WIDE_PTR_PTR34]], ptr [[PTR39]], align 8 -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP41]], ptr align 8 [[T]], i64 16, i1 false) -// CHECK-NEXT: [[CNT142:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[AGG_TEMP41]], i32 0, i32 0 +// CHECK-NEXT: [[CNT142:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[T]], i32 0, i32 0 // CHECK-NEXT: [[TMP5:%.*]] = load i32, ptr [[CNT142]], align 8 -// CHECK-NEXT: [[CNT243:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[AGG_TEMP41]], i32 0, i32 1 +// CHECK-NEXT: [[CNT243:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[T]], i32 0, i32 1 // CHECK-NEXT: [[TMP6:%.*]] = load i32, ptr [[CNT243]], align 4 -// CHECK-NEXT: [[PTR44:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[AGG_TEMP41]], i32 0, i32 2 +// CHECK-NEXT: [[PTR44:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[T]], i32 0, i32 2 // CHECK-NEXT: [[TMP7:%.*]] = load ptr, ptr [[PTR44]], align 8 // CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 2, [[TMP5]] // CHECK-NEXT: [[MUL45:%.*]] = mul nsw i32 3, [[TMP6]] @@ -139,17 +137,17 @@ struct T { // CHECK-NEXT: [[WIDE_PTR_LB_ADDR50:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP40]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB51:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR50]], align 8 // CHECK-NEXT: [[TMP13:%.*]] = icmp ult ptr [[TMP12]], [[WIDE_PTR_UB49]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP13]], label [[CONT53:%.*]], label [[TRAP52:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap52: +// CHECK-NEXT: br i1 [[TMP13]], label %[[CONT53:.*]], label %[[TRAP52:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP52]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont53: +// CHECK: [[CONT53]]: // CHECK-NEXT: [[TMP14:%.*]] = icmp uge ptr [[TMP12]], [[WIDE_PTR_LB51]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP14]], label [[CONT55:%.*]], label [[TRAP54:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap54: +// CHECK-NEXT: br i1 [[TMP14]], label %[[CONT55:.*]], label %[[TRAP54:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP54]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont55: +// CHECK: [[CONT55]]: // CHECK-NEXT: [[TMP15:%.*]] = load i32, ptr [[TMP12]], align 4 // CHECK-NEXT: ret i32 [[TMP15]] // diff --git a/clang/test/BoundsSafety-legacy-checks/Profile/flexible-array-member-checks-code-coverage.c b/clang/test/BoundsSafety-legacy-checks/Profile/flexible-array-member-checks-code-coverage.c index d2cab464c8bf3..6228d557954f4 100644 --- a/clang/test/BoundsSafety-legacy-checks/Profile/flexible-array-member-checks-code-coverage.c +++ b/clang/test/BoundsSafety-legacy-checks/Profile/flexible-array-member-checks-code-coverage.c @@ -19,30 +19,30 @@ void bar(struct s *p); // CHECK-NEXT: store i64 [[TMP0]], ptr @__profc_foo, align 8 // CHECK-NEXT: [[IDX_EXT:%.*]] = zext i32 [[SIZE]] to i64 // CHECK-NEXT: [[FLEX_BASE_NULL_CHECK_NOT:%.*]] = icmp eq ptr [[BUF]], null, {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[FLEX_BASE_NULL_CHECK_NOT]], label [[CONT40:%.*]], label [[FLEX_BASE_NONNULL:%.*]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[FLEX_BASE_NULL_CHECK_NOT]], label %[[CONT40:.*]], label [[FLEX_BASE_NONNULL:%.*]], {{!annotation ![0-9]+}} // CHECK: flex.base.nonnull: // CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[BUF]], i64 [[IDX_EXT]] // CHECK-NEXT: [[TMP1:%.*]] = getelementptr i8, ptr [[BUF]], i64 4 // CHECK-NEXT: [[DOTNOT:%.*]] = icmp ult ptr [[TMP1]], [[BUF]], {{!annotation ![0-9]+}} // CHECK-NEXT: [[DOTNOT49:%.*]] = icmp ugt ptr [[TMP1]], [[ADD_PTR]], {{!annotation ![0-9]+}} // CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[DOTNOT]], i1 true, i1 [[DOTNOT49]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[OR_COND]], label [[TRAP:%.*]], label [[CONT27:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap: +// CHECK-NEXT: br i1 [[OR_COND]], label %[[TRAP:.*]], label %[[CONT27:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP]]: // CHECK-NEXT: tail call void @llvm.ubsantrap(i8 25) #[[ATTR3:[0-9]+]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont27: +// CHECK: [[CONT27]]: // CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[BUF]], align 4, {{!tbaa ![0-9]+}} // CHECK-NEXT: [[FLEX_COUNT_MINUS:%.*]] = icmp sgt i32 [[TMP2]], -1, {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[FLEX_COUNT_MINUS]], label [[CONT30:%.*]], label [[TRAP]], {{!annotation ![0-9]+}} -// CHECK: cont30: +// CHECK-NEXT: br i1 [[FLEX_COUNT_MINUS]], label %[[CONT30:.*]], label %[[TRAP]], {{!annotation ![0-9]+}} +// CHECK: [[CONT30]]: // CHECK-NEXT: [[GEPDIFF:%.*]] = add nsw i64 [[IDX_EXT]], -4, {{!annotation ![0-9]+}} // CHECK-NEXT: [[FLEX_AVAIL_COUNT_DIV:%.*]] = ashr exact i64 [[GEPDIFF]], 2, {{!annotation ![0-9]+}} // CHECK-NEXT: [[FLEX_COUNT_INTPTR:%.*]] = zext nneg i32 [[TMP2]] to i64, {{!annotation ![0-9]+}} // CHECK-NEXT: [[FLEX_COUNT_CHECK_NOT:%.*]] = icmp ult i64 [[FLEX_AVAIL_COUNT_DIV]], [[FLEX_COUNT_INTPTR]], {{!annotation ![0-9]+}} // CHECK-NEXT: [[DOTNOT50:%.*]] = icmp eq i32 [[SIZE]], 0, {{!annotation ![0-9]+}} // CHECK-NEXT: [[OR_COND52:%.*]] = or i1 [[DOTNOT50]], [[FLEX_COUNT_CHECK_NOT]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[OR_COND52]], label [[TRAP]], label [[CONT40]], {{!annotation ![0-9]+}} -// CHECK: cont40: +// CHECK-NEXT: br i1 [[OR_COND52]], label %[[TRAP]], label %[[CONT40]], {{!annotation ![0-9]+}} +// CHECK: [[CONT40]]: // CHECK-NEXT: tail call void @bar(ptr noundef [[BUF]]) #[[ATTR4:[0-9]+]] // CHECK-NEXT: ret void // From d2aa2742cc6f4885d9825b65e3982cf98069e8a7 Mon Sep 17 00:00:00 2001 From: Yeoul Na Date: Tue, 25 Mar 2025 11:14:22 -0700 Subject: [PATCH 4/4] [BoundsSafety][NFC] Adjust BoundsSafety codegen tests --- .../CodeGen/array_subscript_agg.c | 36 ++-- .../CodeGen/builtin-memcpy-count-annotation.c | 2 +- .../CodeGen/call-with-count-ptr.c | 4 +- .../cast-to-count-argument-stmt-expr.c | 12 +- .../CodeGen/constant-eval-count-static-init.c | 20 +- .../count-attr-fields-assign-2-oob2.c | 93 ++++----- .../counted-to-counted-assignments.c | 70 ++++--- .../CodeGen/ended_by_assign_checks_seq-O2.c | 2 +- .../CodeGen/ended_by_assign_checks_seq.c | 20 +- .../CodeGen/ended_by_bag_of_bytes.c | 14 +- .../CodeGen/flexible-array-member-bidi-O0.c | 32 ++- ...e-array-member-promotion-call-builtin-O2.c | 132 ++++++------- .../flexible-array-member-promotion-deref.c | 164 ++++++++------- ...exible-array-member-promotion-returns-O2.c | 14 +- .../BoundsSafety/CodeGen/multiple-dependees.c | 26 ++- .../CodeGen/nested-flexible-array-member-O2.c | 5 +- ...sted-flexible-array-member-nested-len-O2.c | 5 +- .../nested-flexible-array-member-nested-len.c | 187 +++++++++--------- .../CodeGen/nested-flexible-array-member.c | 181 +++++++++-------- ...exible-array-member-checks-code-coverage.c | 14 +- 20 files changed, 492 insertions(+), 541 deletions(-) diff --git a/clang/test/BoundsSafety/CodeGen/array_subscript_agg.c b/clang/test/BoundsSafety/CodeGen/array_subscript_agg.c index 4a7025b070678..306cabda36cbc 100644 --- a/clang/test/BoundsSafety/CodeGen/array_subscript_agg.c +++ b/clang/test/BoundsSafety/CodeGen/array_subscript_agg.c @@ -814,17 +814,15 @@ struct HasFAM { // NEW-NEXT: [[IDX_ADDR:%.*]] = alloca i32, align 4 // NEW-NEXT: [[AGG_TEMP:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // NEW-NEXT: [[AGG_TEMP1:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 -// NEW-NEXT: [[AGG_TEMP2:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 -// NEW-NEXT: [[AGG_TEMP5:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 +// NEW-NEXT: [[AGG_TEMP4:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 // NEW-NEXT: store ptr [[HAS_FAM]], ptr [[HAS_FAM_INDIRECT_ADDR]], align 8 // NEW-NEXT: store i32 [[IDX]], ptr [[IDX_ADDR]], align 4 // NEW-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP1]], ptr align 8 [[HAS_FAM]], i64 24, i1 false) -// NEW-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP2]], ptr align 8 [[AGG_TEMP1]], i64 24, i1 false) -// NEW-NEXT: [[WIDE_PTR_PTR_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 0 +// NEW-NEXT: [[WIDE_PTR_PTR_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP1]], i32 0, i32 0 // NEW-NEXT: [[WIDE_PTR_PTR:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR]], align 8 -// NEW-NEXT: [[WIDE_PTR_UB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 1 +// NEW-NEXT: [[WIDE_PTR_UB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP1]], i32 0, i32 1 // NEW-NEXT: [[WIDE_PTR_UB:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR]], align 8 -// NEW-NEXT: [[WIDE_PTR_LB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 2 +// NEW-NEXT: [[WIDE_PTR_LB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP1]], i32 0, i32 2 // NEW-NEXT: [[WIDE_PTR_LB:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR]], align 8 // NEW-NEXT: [[TMP0:%.*]] = getelementptr [[STRUCT_HASFAM:%.*]], ptr [[WIDE_PTR_PTR]], i64 1 // NEW-NEXT: [[TMP1:%.*]] = icmp ule ptr [[TMP0]], [[WIDE_PTR_UB]], !annotation [[META5:![0-9]+]] @@ -841,12 +839,12 @@ struct HasFAM { // NEW: [[CONT4]]: // NEW-NEXT: [[FAM:%.*]] = getelementptr inbounds [[STRUCT_HASFAM]], ptr [[WIDE_PTR_PTR]], i32 0, i32 1 // NEW-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [0 x %struct.Foo], ptr [[FAM]], i64 0, i64 0 -// NEW-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP5]], ptr align 8 [[AGG_TEMP1]], i64 24, i1 false) -// NEW-NEXT: [[WIDE_PTR_UB_ADDR6:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP5]], i32 0, i32 1 +// NEW-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP4]], ptr align 8 [[HAS_FAM]], i64 24, i1 false) +// NEW-NEXT: [[WIDE_PTR_UB_ADDR6:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP4]], i32 0, i32 1 // NEW-NEXT: [[WIDE_PTR_UB7:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR6]], align 8 -// NEW-NEXT: [[TMP3:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP5]], i32 0, i32 0 +// NEW-NEXT: [[TMP3:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP4]], i32 0, i32 0 // NEW-NEXT: store ptr [[WIDE_PTR_UB7]], ptr [[TMP3]], align 8 -// NEW-NEXT: [[WIDE_PTR_PTR_ADDR8:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP5]], i32 0, i32 0 +// NEW-NEXT: [[WIDE_PTR_PTR_ADDR8:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP4]], i32 0, i32 0 // NEW-NEXT: [[WIDE_PTR_PTR9:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR8]], align 8 // NEW-NEXT: [[TMP4:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP]], i32 0, i32 0 // NEW-NEXT: store ptr [[ARRAYDECAY]], ptr [[TMP4]], align 8 @@ -894,17 +892,15 @@ struct HasFAM { // LEGACY-NEXT: [[IDX_ADDR:%.*]] = alloca i32, align 4 // LEGACY-NEXT: [[AGG_TEMP:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // LEGACY-NEXT: [[AGG_TEMP1:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 -// LEGACY-NEXT: [[AGG_TEMP2:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 -// LEGACY-NEXT: [[AGG_TEMP5:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 +// LEGACY-NEXT: [[AGG_TEMP4:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 // LEGACY-NEXT: store ptr [[HAS_FAM]], ptr [[HAS_FAM_INDIRECT_ADDR]], align 8 // LEGACY-NEXT: store i32 [[IDX]], ptr [[IDX_ADDR]], align 4 // LEGACY-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP1]], ptr align 8 [[HAS_FAM]], i64 24, i1 false) -// LEGACY-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP2]], ptr align 8 [[AGG_TEMP1]], i64 24, i1 false) -// LEGACY-NEXT: [[WIDE_PTR_PTR_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 0 +// LEGACY-NEXT: [[WIDE_PTR_PTR_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP1]], i32 0, i32 0 // LEGACY-NEXT: [[WIDE_PTR_PTR:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR]], align 8 -// LEGACY-NEXT: [[WIDE_PTR_UB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 1 +// LEGACY-NEXT: [[WIDE_PTR_UB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP1]], i32 0, i32 1 // LEGACY-NEXT: [[WIDE_PTR_UB:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR]], align 8 -// LEGACY-NEXT: [[WIDE_PTR_LB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 2 +// LEGACY-NEXT: [[WIDE_PTR_LB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP1]], i32 0, i32 2 // LEGACY-NEXT: [[WIDE_PTR_LB:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR]], align 8 // LEGACY-NEXT: [[TMP0:%.*]] = getelementptr [[STRUCT_HASFAM:%.*]], ptr [[WIDE_PTR_PTR]], i64 1 // LEGACY-NEXT: [[TMP1:%.*]] = icmp ule ptr [[TMP0]], [[WIDE_PTR_UB]], !annotation [[META3:![0-9]+]] @@ -921,12 +917,12 @@ struct HasFAM { // LEGACY: [[CONT4]]: // LEGACY-NEXT: [[FAM:%.*]] = getelementptr inbounds [[STRUCT_HASFAM]], ptr [[WIDE_PTR_PTR]], i32 0, i32 1 // LEGACY-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [0 x %struct.Foo], ptr [[FAM]], i64 0, i64 0 -// LEGACY-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP5]], ptr align 8 [[AGG_TEMP1]], i64 24, i1 false) -// LEGACY-NEXT: [[WIDE_PTR_UB_ADDR6:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP5]], i32 0, i32 1 +// LEGACY-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP4]], ptr align 8 [[HAS_FAM]], i64 24, i1 false) +// LEGACY-NEXT: [[WIDE_PTR_UB_ADDR6:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP4]], i32 0, i32 1 // LEGACY-NEXT: [[WIDE_PTR_UB7:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR6]], align 8 -// LEGACY-NEXT: [[TMP3:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP5]], i32 0, i32 0 +// LEGACY-NEXT: [[TMP3:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP4]], i32 0, i32 0 // LEGACY-NEXT: store ptr [[WIDE_PTR_UB7]], ptr [[TMP3]], align 8 -// LEGACY-NEXT: [[WIDE_PTR_PTR_ADDR8:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP5]], i32 0, i32 0 +// LEGACY-NEXT: [[WIDE_PTR_PTR_ADDR8:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP4]], i32 0, i32 0 // LEGACY-NEXT: [[WIDE_PTR_PTR9:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR8]], align 8 // LEGACY-NEXT: [[TMP4:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP]], i32 0, i32 0 // LEGACY-NEXT: store ptr [[ARRAYDECAY]], ptr [[TMP4]], align 8 diff --git a/clang/test/BoundsSafety/CodeGen/builtin-memcpy-count-annotation.c b/clang/test/BoundsSafety/CodeGen/builtin-memcpy-count-annotation.c index 3b947bc2c0a35..8669009dc5354 100644 --- a/clang/test/BoundsSafety/CodeGen/builtin-memcpy-count-annotation.c +++ b/clang/test/BoundsSafety/CodeGen/builtin-memcpy-count-annotation.c @@ -249,7 +249,7 @@ // CHECK-NEXT: br label %[[LAND_END144]] // CHECK: [[LAND_END144]]: {{.*}} // CHECK-NEXT: [[TMP25:%.*]] = phi i1 [ false, %[[LAND_LHS_TRUE91]] ], [ false, [[CONT]] ], [ [[CMP143]], %[[LAND_RHS109]] ], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP25]], label %[[CONT146:.*]], label %[[TRAP145:.*]], {{!prof ![0-9]+}}, {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[TMP25]], label %[[CONT146:.*]], label %[[TRAP145:.*]], {{!annotation ![0-9]+}} // CHECK: [[TRAP145]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR5]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable diff --git a/clang/test/BoundsSafety/CodeGen/call-with-count-ptr.c b/clang/test/BoundsSafety/CodeGen/call-with-count-ptr.c index 7517450b9b3e6..4f4b96fbaded8 100644 --- a/clang/test/BoundsSafety/CodeGen/call-with-count-ptr.c +++ b/clang/test/BoundsSafety/CodeGen/call-with-count-ptr.c @@ -240,7 +240,7 @@ int arr[] = {0, 1, 2, 3, 4, 5}; // CHECK_X64_O0-NEXT: br label [[LAND_END]] // CHECK_X64_O0: land.end: // CHECK_X64_O0-NEXT: [[TMP38:%.*]] = phi i1 [ false, [[LAND_LHS_TRUE]] ], [ false, [[CONT]] ], [ [[CMP116]], [[LAND_RHS]] ], {{!annotation ![0-9]+}} -// CHECK_X64_O0-NEXT: br i1 [[TMP38]], label %[[CONT118:.*]], label %[[TRAP117:.*]], {{!prof ![0-9]+}}, {{!annotation ![0-9]+}} +// CHECK_X64_O0-NEXT: br i1 [[TMP38]], label %[[CONT118:.*]], label %[[TRAP117:.*]], {{!annotation ![0-9]+}} // CHECK_X64_O0: [[TRAP117]]: // CHECK_X64_O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR5]], {{!annotation ![0-9]+}} // CHECK_X64_O0-NEXT: unreachable @@ -490,7 +490,7 @@ int arr[] = {0, 1, 2, 3, 4, 5}; // CHECK_ARM64_O0-NEXT: br label [[LAND_END]] // CHECK_ARM64_O0: land.end: // CHECK_ARM64_O0-NEXT: [[TMP38:%.*]] = phi i1 [ false, [[LAND_LHS_TRUE]] ], [ false, [[CONT]] ], [ [[CMP116]], [[LAND_RHS]] ], {{!annotation ![0-9]+}} -// CHECK_ARM64_O0-NEXT: br i1 [[TMP38]], label %[[CONT118:.*]], label %[[TRAP117:.*]], {{!prof ![0-9]+}}, {{!annotation ![0-9]+}} +// CHECK_ARM64_O0-NEXT: br i1 [[TMP38]], label %[[CONT118:.*]], label %[[TRAP117:.*]], {{!annotation ![0-9]+}} // CHECK_ARM64_O0: [[TRAP117]]: // CHECK_ARM64_O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR5]], {{!annotation ![0-9]+}} // CHECK_ARM64_O0-NEXT: unreachable diff --git a/clang/test/BoundsSafety/CodeGen/cast-to-count-argument-stmt-expr.c b/clang/test/BoundsSafety/CodeGen/cast-to-count-argument-stmt-expr.c index c5f7b0bf4b90c..7121f4fec09d7 100644 --- a/clang/test/BoundsSafety/CodeGen/cast-to-count-argument-stmt-expr.c +++ b/clang/test/BoundsSafety/CodeGen/cast-to-count-argument-stmt-expr.c @@ -31,7 +31,6 @@ void Foo(int *__indexable ptr); // CHECK-NEXT: [[AGG_TEMP27:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP30:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP42:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-NEXT: [[AGG_TEMP51:%.*]] = alloca [[STRUCT_S]], align 8 // CHECK-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [10 x i32], ptr [[ARR]], i64 0, i64 0 // CHECK-NEXT: [[UPPER:%.*]] = getelementptr inbounds i32, ptr [[ARRAYDECAY]], i64 10 // CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[TMP]], i32 0, i32 0 @@ -144,10 +143,9 @@ void Foo(int *__indexable ptr); // CHECK-NEXT: store ptr [[WIDE_PTR_PTR44]], ptr [[BUF49]], align 8 // CHECK-NEXT: [[LEN50:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 0 // CHECK-NEXT: store i32 0, ptr [[LEN50]], align 8 -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP51]], ptr align 8 [[S]], i64 16, i1 false) -// CHECK-NEXT: [[LEN52:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP51]], i32 0, i32 0 +// CHECK-NEXT: [[LEN52:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 0 // CHECK-NEXT: [[TMP17:%.*]] = load i32, ptr [[LEN52]], align 8 -// CHECK-NEXT: [[BUF53:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP51]], i32 0, i32 1 +// CHECK-NEXT: [[BUF53:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 1 // CHECK-NEXT: [[TMP18:%.*]] = load ptr, ptr [[BUF53]], align 8 // CHECK-NEXT: [[IDX_EXT:%.*]] = sext i32 [[TMP17]] to i64 // CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr [[TMP18]], i64 [[IDX_EXT]] @@ -165,11 +163,11 @@ void Foo(int *__indexable ptr); // CHECK-NEXT: [[WIDE_PTR_LB_ADDR58:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB59:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR58]], align 8 // CHECK-NEXT: [[TMP22:%.*]] = icmp uge ptr [[WIDE_PTR_PTR55]], [[WIDE_PTR_LB59]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP22]], label [[CONT61:%.*]], label [[TRAP60:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap60: +// CHECK-NEXT: br i1 [[TMP22]], label %[[CONT61:.*]], label %[[TRAP60:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP60]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR5]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable -// CHECK: cont61: +// CHECK: [[CONT61]]: // CHECK-NEXT: [[TMP23:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.indexable", ptr [[AGG_TMP]], i32 0, i32 0 // CHECK-NEXT: store ptr [[WIDE_PTR_PTR55]], ptr [[TMP23]], align 8 // CHECK-NEXT: [[TMP24:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.indexable", ptr [[AGG_TMP]], i32 0, i32 1 diff --git a/clang/test/BoundsSafety/CodeGen/constant-eval-count-static-init.c b/clang/test/BoundsSafety/CodeGen/constant-eval-count-static-init.c index 11e91926c6729..1ff01ac46d784 100644 --- a/clang/test/BoundsSafety/CodeGen/constant-eval-count-static-init.c +++ b/clang/test/BoundsSafety/CodeGen/constant-eval-count-static-init.c @@ -16,13 +16,9 @@ const Item oidRsa = { _oidRsa, sizeof(_oidRsa)}; // CHECK-NEXT: entry: // CHECK-NEXT: [[RETVAL:%.*]] = alloca i32, align 4 // CHECK-NEXT: [[AGG_TEMP:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-NEXT: [[AGG_TEMP1:%.*]] = alloca [[STRUCT_ITEM:%.*]], align 8 // CHECK-NEXT: store i32 0, ptr [[RETVAL]], align 4 -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP1]], ptr align 8 @oidRsa, i64 16, i1 false) -// CHECK-NEXT: [[LENGTH:%.*]] = getelementptr inbounds [[STRUCT_ITEM]], ptr [[AGG_TEMP1]], i32 0, i32 1 -// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[LENGTH]], align 8 -// CHECK-NEXT: [[DATA:%.*]] = getelementptr inbounds [[STRUCT_ITEM]], ptr [[AGG_TEMP1]], i32 0, i32 0 -// CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[DATA]], align 8 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr getelementptr inbounds ([[STRUCT_ITEM:%.*]], ptr @oidRsa, i32 0, i32 1), align 8 +// CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr @oidRsa, align 8 // CHECK-NEXT: [[IDX_EXT:%.*]] = sext i32 [[TMP0]] to i64 // CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[TMP1]], i64 [[IDX_EXT]] // CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP]], i32 0, i32 0 @@ -46,17 +42,17 @@ const Item oidRsa = { _oidRsa, sizeof(_oidRsa)}; // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} // CHECK: cont: // CHECK-NEXT: [[TMP7:%.*]] = icmp ule ptr [[ARRAYIDX]], [[TMP5]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP7]], label [[CONT3:%.*]], label [[TRAP2:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap2: +// CHECK-NEXT: br i1 [[TMP7]], label %[[CONT3:.*]], label %[[TRAP2:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP2]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont3: +// CHECK: [[CONT3]]: // CHECK-NEXT: [[TMP8:%.*]] = icmp uge ptr [[ARRAYIDX]], [[WIDE_PTR_LB]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP8]], label [[CONT5:%.*]], label [[TRAP4:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap4: +// CHECK-NEXT: br i1 [[TMP8]], label %[[CONT5:.*]], label %[[TRAP4:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP4]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont5: +// CHECK: [[CONT5]]: // CHECK-NEXT: [[TMP9:%.*]] = load i32, ptr [[ARRAYIDX]], align 4 // CHECK-NEXT: ret i32 [[TMP9]] // diff --git a/clang/test/BoundsSafety/CodeGen/count-dependent-assignment-checks/count-attr-fields-assign-2-oob2.c b/clang/test/BoundsSafety/CodeGen/count-dependent-assignment-checks/count-attr-fields-assign-2-oob2.c index 048dda93d1cdd..639054fde3487 100644 --- a/clang/test/BoundsSafety/CodeGen/count-dependent-assignment-checks/count-attr-fields-assign-2-oob2.c +++ b/clang/test/BoundsSafety/CodeGen/count-dependent-assignment-checks/count-attr-fields-assign-2-oob2.c @@ -26,11 +26,8 @@ struct S { // CHECK-O0-NEXT: [[AGG_TEMP33:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-O0-NEXT: [[I:%.*]] = alloca i32, align 4 // CHECK-O0-NEXT: [[AGG_TEMP42:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-O0-NEXT: [[AGG_TEMP43:%.*]] = alloca [[STRUCT_S]], align 8 // CHECK-O0-NEXT: [[AGG_TEMP58:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-O0-NEXT: [[AGG_TEMP59:%.*]] = alloca [[STRUCT_S]], align 8 // CHECK-O0-NEXT: [[AGG_TEMP77:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-O0-NEXT: [[AGG_TEMP78:%.*]] = alloca [[STRUCT_S]], align 8 // CHECK-O0-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [10 x i32], ptr [[ARR]], i64 0, i64 0 // CHECK-O0-NEXT: [[UPPER:%.*]] = getelementptr inbounds i32, ptr [[ARRAYDECAY]], i64 10 // CHECK-O0-NEXT: [[TMP0:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[TMP]], i32 0, i32 0 @@ -146,10 +143,9 @@ struct S { // CHECK-O0-NEXT: br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]] // CHECK-O0: for.body: // CHECK-O0-NEXT: [[TMP23:%.*]] = load i32, ptr [[I]], align 4 -// CHECK-O0-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP43]], ptr align 8 [[S]], i64 24, i1 false) -// CHECK-O0-NEXT: [[L44:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP43]], i32 0, i32 2 +// CHECK-O0-NEXT: [[L44:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 2 // CHECK-O0-NEXT: [[TMP24:%.*]] = load i32, ptr [[L44]], align 8 -// CHECK-O0-NEXT: [[BP45:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP43]], i32 0, i32 0 +// CHECK-O0-NEXT: [[BP45:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 0 // CHECK-O0-NEXT: [[TMP25:%.*]] = load ptr, ptr [[BP45]], align 8 // CHECK-O0-NEXT: [[IDX_EXT:%.*]] = sext i32 [[TMP24]] to i64 // CHECK-O0-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr [[TMP25]], i64 [[IDX_EXT]] @@ -170,23 +166,23 @@ struct S { // CHECK-O0-NEXT: [[WIDE_PTR_LB51:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR50]], align 8 // CHECK-O0-NEXT: [[TMP30:%.*]] = getelementptr i32, ptr [[ARRAYIDX]], i64 1, {{!annotation ![0-9]+}} // CHECK-O0-NEXT: [[TMP31:%.*]] = icmp ule ptr [[TMP30]], [[WIDE_PTR_UB49]], {{!annotation ![0-9]+}} -// CHECK-O0-NEXT: br i1 [[TMP31]], label [[CONT53:%.*]], label [[TRAP52:%.*]], {{!annotation ![0-9]+}} -// CHECK-O0: trap52: +// CHECK-O0-NEXT: br i1 [[TMP31]], label %[[CONT53:.*]], label %[[TRAP52:.*]], {{!annotation ![0-9]+}} +// CHECK-O0: [[TRAP52]]: // CHECK-O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-O0-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK-O0: cont53: +// CHECK-O0: [[CONT53]]: // CHECK-O0-NEXT: [[TMP32:%.*]] = icmp ule ptr [[ARRAYIDX]], [[TMP30]], {{!annotation ![0-9]+}} -// CHECK-O0-NEXT: br i1 [[TMP32]], label [[CONT55:%.*]], label [[TRAP54:%.*]], {{!annotation ![0-9]+}} -// CHECK-O0: trap54: +// CHECK-O0-NEXT: br i1 [[TMP32]], label %[[CONT55:.*]], label %[[TRAP54:.*]], {{!annotation ![0-9]+}} +// CHECK-O0: [[TRAP54]]: // CHECK-O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-O0-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK-O0: cont55: +// CHECK-O0: [[CONT55]]: // CHECK-O0-NEXT: [[TMP33:%.*]] = icmp uge ptr [[ARRAYIDX]], [[WIDE_PTR_LB51]], {{!annotation ![0-9]+}} -// CHECK-O0-NEXT: br i1 [[TMP33]], label [[CONT57:%.*]], label [[TRAP56:%.*]], {{!annotation ![0-9]+}} -// CHECK-O0: trap56: +// CHECK-O0-NEXT: br i1 [[TMP33]], label %[[CONT57:.*]], label %[[TRAP56:.*]], {{!annotation ![0-9]+}} +// CHECK-O0: [[TRAP56]]: // CHECK-O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-O0-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK-O0: cont57: +// CHECK-O0: [[CONT57]]: // CHECK-O0-NEXT: store i32 [[TMP23]], ptr [[ARRAYIDX]], align 4 // CHECK-O0-NEXT: br label [[FOR_INC:%.*]] // CHECK-O0: for.inc: @@ -195,10 +191,9 @@ struct S { // CHECK-O0-NEXT: store i32 [[INC]], ptr [[I]], align 4 // CHECK-O0-NEXT: br label [[FOR_COND]], !llvm.loop [[LOOP5:![0-9]+]] // CHECK-O0: for.end: -// CHECK-O0-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP59]], ptr align 8 [[S]], i64 24, i1 false) -// CHECK-O0-NEXT: [[L60:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP59]], i32 0, i32 2 +// CHECK-O0-NEXT: [[L60:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 2 // CHECK-O0-NEXT: [[TMP35:%.*]] = load i32, ptr [[L60]], align 8 -// CHECK-O0-NEXT: [[BP261:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP59]], i32 0, i32 1 +// CHECK-O0-NEXT: [[BP261:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 1 // CHECK-O0-NEXT: [[TMP36:%.*]] = load ptr, ptr [[BP261]], align 8 // CHECK-O0-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP35]], 1 // CHECK-O0-NEXT: [[IDX_EXT62:%.*]] = sext i32 [[ADD]] to i64 @@ -217,39 +212,35 @@ struct S { // CHECK-O0-NEXT: [[WIDE_PTR_LB_ADDR69:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP58]], i32 0, i32 2 // CHECK-O0-NEXT: [[WIDE_PTR_LB70:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR69]], align 8 // CHECK-O0-NEXT: [[TMP40:%.*]] = getelementptr i32, ptr [[ARRAYIDX66]], i64 1, {{!annotation ![0-9]+}} +// COM: rdar://154226004 (Seemingly necessary range check (ptr <= ptr + 1) has been removed after fixing materialization bug for LValues) +// COM: These checks preserve as expected: lower <= arrayidx66(ptr + 8), tmp41 (ptr + 9) <= upper +// COM: This check has been dropped. Not sure why: arrayidx66(ptr + 8) <= tmp41(ptr + 9) // CHECK-O0-NEXT: [[TMP41:%.*]] = icmp ule ptr [[TMP40]], [[WIDE_PTR_UB68]], {{!annotation ![0-9]+}} // CHECK-O0-NEXT: br i1 [[TMP41]], label [[CONT72:%.*]], label [[TRAP71:%.*]], {{!annotation ![0-9]+}} // CHECK-O0: trap71: // CHECK-O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-O0-NEXT: unreachable, {{!annotation ![0-9]+}} // CHECK-O0: cont72: -// CHECK-O0-NEXT: [[TMP42:%.*]] = icmp ule ptr [[ARRAYIDX66]], [[TMP40]], {{!annotation ![0-9]+}} -// CHECK-O0-NEXT: br i1 [[TMP42]], label [[CONT74:%.*]], label [[TRAP73:%.*]], {{!annotation ![0-9]+}} +// CHECK-O0-NEXT: [[TMP43:%.*]] = icmp uge ptr [[ARRAYIDX66]], [[WIDE_PTR_LB70]], {{!annotation ![0-9]+}} +// CHECK-O0-NEXT: br i1 [[TMP43]], label [[CONT74:%.*]], label [[TRAP73:%.*]], {{!annotation ![0-9]+}} // CHECK-O0: trap73: // CHECK-O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-O0-NEXT: unreachable, {{!annotation ![0-9]+}} // CHECK-O0: cont74: -// CHECK-O0-NEXT: [[TMP43:%.*]] = icmp uge ptr [[ARRAYIDX66]], [[WIDE_PTR_LB70]], {{!annotation ![0-9]+}} -// CHECK-O0-NEXT: br i1 [[TMP43]], label [[CONT76:%.*]], label [[TRAP75:%.*]], {{!annotation ![0-9]+}} -// CHECK-O0: trap75: -// CHECK-O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} -// CHECK-O0-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK-O0: cont76: -// CHECK-O0-NEXT: [[TMP44:%.*]] = load i32, ptr [[ARRAYIDX66]], align 4 -// CHECK-O0-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP78]], ptr align 8 [[S]], i64 24, i1 false) -// CHECK-O0-NEXT: [[L79:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP78]], i32 0, i32 2 -// CHECK-O0-NEXT: [[TMP45:%.*]] = load i32, ptr [[L79]], align 8 -// CHECK-O0-NEXT: [[BP80:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP78]], i32 0, i32 0 -// CHECK-O0-NEXT: [[TMP46:%.*]] = load ptr, ptr [[BP80]], align 8 -// CHECK-O0-NEXT: [[IDX_EXT81:%.*]] = sext i32 [[TMP45]] to i64 -// CHECK-O0-NEXT: [[ADD_PTR82:%.*]] = getelementptr inbounds i32, ptr [[TMP46]], i64 [[IDX_EXT81]] -// CHECK-O0-NEXT: [[TMP47:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP77]], i32 0, i32 0 -// CHECK-O0-NEXT: store ptr [[TMP46]], ptr [[TMP47]], align 8 -// CHECK-O0-NEXT: [[TMP48:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP77]], i32 0, i32 1 -// CHECK-O0-NEXT: store ptr [[ADD_PTR82]], ptr [[TMP48]], align 8 -// CHECK-O0-NEXT: [[TMP49:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP77]], i32 0, i32 2 -// CHECK-O0-NEXT: store ptr [[TMP46]], ptr [[TMP49]], align 8 -// CHECK-O0-NEXT: [[WIDE_PTR_PTR_ADDR83:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP77]], i32 0, i32 0 +// CHECK-O0-NEXT: [[TMP45:%.*]] = load i32, ptr [[ARRAYIDX66]], align 4 +// CHECK-O0-NEXT: [[L79:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 2 +// CHECK-O0-NEXT: [[TMP46:%.*]] = load i32, ptr [[L79]], align 8 +// CHECK-O0-NEXT: [[BP80:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 0 +// CHECK-O0-NEXT: [[TMP47:%.*]] = load ptr, ptr [[BP80]], align 8 +// CHECK-O0-NEXT: [[IDX_EXT81:%.*]] = sext i32 [[TMP46]] to i64 +// CHECK-O0-NEXT: [[ADD_PTR82:%.*]] = getelementptr inbounds i32, ptr [[TMP47]], i64 [[IDX_EXT81]] +// CHECK-O0-NEXT: [[TMP48:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP77]], i32 0, i32 0 +// CHECK-O0-NEXT: store ptr [[TMP47]], ptr [[TMP48]], align 8 +// CHECK-O0-NEXT: [[TMP49:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP77]], i32 0, i32 1 +// CHECK-O0-NEXT: store ptr [[ADD_PTR82]], ptr [[TMP49]], align 8 +// CHECK-O0-NEXT: [[TMP50:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP77]], i32 0, i32 2 +// CHECK-O0-NEXT: store ptr [[TMP47]], ptr [[TMP50]], align 8 +// CHECK-O0-NEXT: [[WIDE_PTR_PTR_ADDR83:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP77]], i32 0, i32 0 // CHECK-O0-NEXT: [[WIDE_PTR_PTR84:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR83]], align 8 // CHECK-O0-NEXT: [[ARRAYIDX85:%.*]] = getelementptr i32, ptr [[WIDE_PTR_PTR84]], i64 8 // CHECK-O0-NEXT: [[WIDE_PTR_UB_ADDR86:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP77]], i32 0, i32 1 @@ -258,25 +249,25 @@ struct S { // CHECK-O0-NEXT: [[WIDE_PTR_LB89:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR88]], align 8 // CHECK-O0-NEXT: [[TMP50:%.*]] = getelementptr i32, ptr [[ARRAYIDX85]], i64 1, {{!annotation ![0-9]+}} // CHECK-O0-NEXT: [[TMP51:%.*]] = icmp ule ptr [[TMP50]], [[WIDE_PTR_UB87]], {{!annotation ![0-9]+}} -// CHECK-O0-NEXT: br i1 [[TMP51]], label [[CONT91:%.*]], label [[TRAP90:%.*]], {{!annotation ![0-9]+}} -// CHECK-O0: trap90: +// CHECK-O0-NEXT: br i1 [[TMP51]], label %[[CONT91:.*]], label %[[TRAP90:.*]], {{!annotation ![0-9]+}} +// CHECK-O0: [[TRAP90]]: // CHECK-O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-O0-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK-O0: cont91: +// CHECK-O0: [[CONT91]]: // CHECK-O0-NEXT: [[TMP52:%.*]] = icmp ule ptr [[ARRAYIDX85]], [[TMP50]], {{!annotation ![0-9]+}} -// CHECK-O0-NEXT: br i1 [[TMP52]], label [[CONT93:%.*]], label [[TRAP92:%.*]], {{!annotation ![0-9]+}} -// CHECK-O0: trap92: +// CHECK-O0-NEXT: br i1 [[TMP52]], label %[[CONT93:.*]], label %[[TRAP92:.*]], {{!annotation ![0-9]+}} +// CHECK-O0: [[TRAP92]]: // CHECK-O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-O0-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK-O0: cont93: +// CHECK-O0: [[CONT93]]: // CHECK-O0-NEXT: [[TMP53:%.*]] = icmp uge ptr [[ARRAYIDX85]], [[WIDE_PTR_LB89]], {{!annotation ![0-9]+}} -// CHECK-O0-NEXT: br i1 [[TMP53]], label [[CONT95:%.*]], label [[TRAP94:%.*]], {{!annotation ![0-9]+}} -// CHECK-O0: trap94: +// CHECK-O0-NEXT: br i1 [[TMP53]], label %[[CONT95:.*]], label %[[TRAP94:.*]], {{!annotation ![0-9]+}} +// CHECK-O0: [[TRAP94]]: // CHECK-O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-O0-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK-O0: cont95: +// CHECK-O0: [[CONT95]]: // CHECK-O0-NEXT: [[TMP54:%.*]] = load i32, ptr [[ARRAYIDX85]], align 4 -// CHECK-O0-NEXT: [[ADD96:%.*]] = add nsw i32 [[TMP44]], [[TMP54]] +// CHECK-O0-NEXT: [[ADD96:%.*]] = add nsw i32 [[TMP45]], [[TMP54]] // CHECK-O0-NEXT: ret i32 [[ADD96]] // // CHECK-O2-LABEL: @foo( diff --git a/clang/test/BoundsSafety/CodeGen/count-dependent-assignment-checks/counted-to-counted-assignments.c b/clang/test/BoundsSafety/CodeGen/count-dependent-assignment-checks/counted-to-counted-assignments.c index 968323258d9d2..9e58760fdd16b 100644 --- a/clang/test/BoundsSafety/CodeGen/count-dependent-assignment-checks/counted-to-counted-assignments.c +++ b/clang/test/BoundsSafety/CodeGen/count-dependent-assignment-checks/counted-to-counted-assignments.c @@ -18,7 +18,6 @@ struct S { // CHECK-NEXT: [[AGG_TEMP:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP7:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP14:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-NEXT: [[AGG_TEMP15:%.*]] = alloca [[STRUCT_S]], align 8 // CHECK-NEXT: [[AGG_TEMP18:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP21:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP28:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 @@ -89,10 +88,9 @@ struct S { // CHECK-NEXT: store i32 10, ptr [[LEN]], align 8 // CHECK-NEXT: br label [[HERE:%.*]] // CHECK: here: -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP15]], ptr align 8 [[S]], i64 24, i1 false) -// CHECK-NEXT: [[LEN16:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP15]], i32 0, i32 2 +// CHECK-NEXT: [[LEN16:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 2 // CHECK-NEXT: [[TMP15:%.*]] = load i32, ptr [[LEN16]], align 8 -// CHECK-NEXT: [[PTR217:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP15]], i32 0, i32 1 +// CHECK-NEXT: [[PTR217:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 1 // CHECK-NEXT: [[TMP16:%.*]] = load ptr, ptr [[PTR217]], align 8 // CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 [[TMP15]], 1 // CHECK-NEXT: [[IDX_EXT:%.*]] = sext i32 [[SUB]] to i64 @@ -122,7 +120,7 @@ struct S { // CHECK-NEXT: [[WIDE_PTR_UB_ADDR29:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 1, {{!annotation ![0-9]+}} // CHECK-NEXT: [[WIDE_PTR_UB30:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR29]], align 8, {{!annotation ![0-9]+}} // CHECK-NEXT: [[CMP:%.*]] = icmp ule ptr [[WIDE_PTR_PTR23]], [[WIDE_PTR_UB30]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[CMP]], label [[LAND_LHS_TRUE:%.*]], label [[LAND_END54:%.*]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[CMP]], label [[LAND_LHS_TRUE:%.*]], label %[[LAND_END54:.*]], {{!annotation ![0-9]+}} // CHECK: land.lhs.true: // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP31]], ptr align 8 [[AGG_TEMP14]], i64 24, i1 false), {{!annotation ![0-9]+}} // CHECK-NEXT: [[WIDE_PTR_LB_ADDR32:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP31]], i32 0, i32 2, {{!annotation ![0-9]+}} @@ -135,7 +133,7 @@ struct S { // CHECK-NEXT: [[WIDE_PTR_LB_ADDR39:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP34]], i32 0, i32 2, {{!annotation ![0-9]+}} // CHECK-NEXT: [[WIDE_PTR_LB40:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR39]], align 8, {{!annotation ![0-9]+}} // CHECK-NEXT: [[CMP41:%.*]] = icmp ule ptr [[WIDE_PTR_LB33]], [[WIDE_PTR_PTR36]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[CMP41]], label [[LAND_RHS:%.*]], label [[LAND_END54]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[CMP41]], label [[LAND_RHS:%.*]], label %[[LAND_END54]], {{!annotation ![0-9]+}} // CHECK: land.rhs: // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP42]], ptr align 8 [[AGG_TEMP14]], i64 24, i1 false), {{!annotation ![0-9]+}} // CHECK-NEXT: [[WIDE_PTR_UB_ADDR43:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP42]], i32 0, i32 1, {{!annotation ![0-9]+}} @@ -152,24 +150,24 @@ struct S { // CHECK-NEXT: [[SUB_PTR_SUB:%.*]] = sub i64 [[SUB_PTR_LHS_CAST]], [[SUB_PTR_RHS_CAST]], {{!annotation ![0-9]+}} // CHECK-NEXT: [[SUB_PTR_DIV:%.*]] = sdiv exact i64 [[SUB_PTR_SUB]], 4, {{!annotation ![0-9]+}} // CHECK-NEXT: [[CMP52:%.*]] = icmp sle i64 10, [[SUB_PTR_DIV]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[CMP52]], label [[LAND_RHS53:%.*]], label [[LAND_END:%.*]], {{!annotation ![0-9]+}} -// CHECK: land.rhs53: -// CHECK-NEXT: br label [[LAND_END]], {{!annotation ![0-9]+}} -// CHECK: land.end: -// CHECK-NEXT: [[TMP23:%.*]] = phi i1 [ false, [[LAND_RHS]] ], [ true, [[LAND_RHS53]] ] -// CHECK-NEXT: br label [[LAND_END54]], {{!annotation ![0-9]+}} -// CHECK: land.end54: -// CHECK-NEXT: [[TMP24:%.*]] = phi i1 [ false, [[LAND_LHS_TRUE]] ], [ false, [[HERE]] ], [ [[TMP23]], [[LAND_END]] ], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP24]], label [[CONT56:%.*]], label [[TRAP55:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap55: +// CHECK-NEXT: br i1 [[CMP52]], label %[[LAND_RHS53:.*]], label %[[LAND_END:.*]], {{!annotation ![0-9]+}} +// CHECK: [[LAND_RHS53]]: +// CHECK-NEXT: br label %[[LAND_END]], {{!annotation ![0-9]+}} +// CHECK: [[LAND_END]]: +// CHECK-NEXT: [[TMP23:%.*]] = phi i1 [ false, [[LAND_RHS]] ], [ true, %[[LAND_RHS53]] ] +// CHECK-NEXT: br label %[[LAND_END54]], {{!annotation ![0-9]+}} +// CHECK: [[LAND_END54]]: +// CHECK-NEXT: [[TMP24:%.*]] = phi i1 [ false, [[LAND_LHS_TRUE]] ], [ false, [[HERE]] ], [ [[TMP23]], %[[LAND_END]] ], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[TMP24]], label %[[CONT56:.*]], label %[[TRAP55:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP55]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont56: -// CHECK-NEXT: br i1 true, label [[CONT58:%.*]], label [[TRAP57:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap57: +// CHECK: [[CONT56]]: +// CHECK-NEXT: br i1 true, label %[[CONT58:.*]], label %[[TRAP57:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP57]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont58: +// CHECK: [[CONT58]]: // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP59]], ptr align 8 [[AGG_TEMP14]], i64 24, i1 false) // CHECK-NEXT: [[WIDE_PTR_PTR_ADDR60:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP59]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR61:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR60]], align 8 @@ -213,7 +211,6 @@ int Foo() { // CHECK-NEXT: [[AGG_TEMP7:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP14:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[TMP_TMP15:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-NEXT: [[AGG_TEMP16:%.*]] = alloca [[STRUCT_S]], align 8 // CHECK-NEXT: [[AGG_TEMP20:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP23:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP30:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 @@ -284,10 +281,9 @@ int Foo() { // CHECK-NEXT: store i32 10, ptr [[LEN]], align 8 // CHECK-NEXT: br label [[HERE:%.*]] // CHECK: here: -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP16]], ptr align 8 [[S]], i64 24, i1 false) -// CHECK-NEXT: [[LEN17:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP16]], i32 0, i32 2 +// CHECK-NEXT: [[LEN17:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 2 // CHECK-NEXT: [[TMP15:%.*]] = load i32, ptr [[LEN17]], align 8 -// CHECK-NEXT: [[PTR18:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP16]], i32 0, i32 0 +// CHECK-NEXT: [[PTR18:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 0 // CHECK-NEXT: [[TMP16:%.*]] = load ptr, ptr [[PTR18]], align 8 // CHECK-NEXT: [[IDX_EXT:%.*]] = sext i32 [[TMP15]] to i64 // CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr [[TMP16]], i64 [[IDX_EXT]] @@ -329,7 +325,7 @@ int Foo() { // CHECK-NEXT: [[WIDE_PTR_UB_ADDR31:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP30]], i32 0, i32 1, {{!annotation ![0-9]+}} // CHECK-NEXT: [[WIDE_PTR_UB32:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR31]], align 8, {{!annotation ![0-9]+}} // CHECK-NEXT: [[CMP:%.*]] = icmp ule ptr [[WIDE_PTR_PTR25]], [[WIDE_PTR_UB32]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[CMP]], label [[LAND_LHS_TRUE:%.*]], label [[LAND_END56:%.*]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[CMP]], label [[LAND_LHS_TRUE:%.*]], label %[[LAND_END56:.*]], {{!annotation ![0-9]+}} // CHECK: land.lhs.true: // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP33]], ptr align 8 [[AGG_TEMP14]], i64 24, i1 false), {{!annotation ![0-9]+}} // CHECK-NEXT: [[WIDE_PTR_LB_ADDR34:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP33]], i32 0, i32 2, {{!annotation ![0-9]+}} @@ -342,7 +338,7 @@ int Foo() { // CHECK-NEXT: [[WIDE_PTR_LB_ADDR41:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP36]], i32 0, i32 2, {{!annotation ![0-9]+}} // CHECK-NEXT: [[WIDE_PTR_LB42:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR41]], align 8, {{!annotation ![0-9]+}} // CHECK-NEXT: [[CMP43:%.*]] = icmp ule ptr [[WIDE_PTR_LB35]], [[WIDE_PTR_PTR38]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[CMP43]], label [[LAND_RHS:%.*]], label [[LAND_END56]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[CMP43]], label [[LAND_RHS:%.*]], label %[[LAND_END56]], {{!annotation ![0-9]+}} // CHECK: land.rhs: // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP44]], ptr align 8 [[AGG_TEMP14]], i64 24, i1 false), {{!annotation ![0-9]+}} // CHECK-NEXT: [[WIDE_PTR_UB_ADDR45:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP44]], i32 0, i32 1, {{!annotation ![0-9]+}} @@ -359,24 +355,24 @@ int Foo() { // CHECK-NEXT: [[SUB_PTR_SUB:%.*]] = sub i64 [[SUB_PTR_LHS_CAST]], [[SUB_PTR_RHS_CAST]], {{!annotation ![0-9]+}} // CHECK-NEXT: [[SUB_PTR_DIV:%.*]] = sdiv exact i64 [[SUB_PTR_SUB]], 4, {{!annotation ![0-9]+}} // CHECK-NEXT: [[CMP54:%.*]] = icmp sle i64 10, [[SUB_PTR_DIV]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[CMP54]], label [[LAND_RHS55:%.*]], label [[LAND_END:%.*]], {{!annotation ![0-9]+}} -// CHECK: land.rhs55: +// CHECK-NEXT: br i1 [[CMP54]], label %[[LAND_RHS55:.*]], label [[LAND_END:%.*]], {{!annotation ![0-9]+}} +// CHECK: [[LAND_RHS55]]: // CHECK-NEXT: br label [[LAND_END]], {{!annotation ![0-9]+}} // CHECK: land.end: -// CHECK-NEXT: [[TMP32:%.*]] = phi i1 [ false, [[LAND_RHS]] ], [ true, [[LAND_RHS55]] ] -// CHECK-NEXT: br label [[LAND_END56]], {{!annotation ![0-9]+}} -// CHECK: land.end56: +// CHECK-NEXT: [[TMP32:%.*]] = phi i1 [ false, [[LAND_RHS]] ], [ true, %[[LAND_RHS55]] ] +// CHECK-NEXT: br label %[[LAND_END56]], {{!annotation ![0-9]+}} +// CHECK: [[LAND_END56]]: // CHECK-NEXT: [[TMP33:%.*]] = phi i1 [ false, [[LAND_LHS_TRUE]] ], [ false, [[HERE]] ], [ [[TMP32]], [[LAND_END]] ], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP33]], label [[CONT58:%.*]], label [[TRAP57:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap57: +// CHECK-NEXT: br i1 [[TMP33]], label %[[CONT58:.*]], label %[[TRAP57:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP57]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont58: -// CHECK-NEXT: br i1 true, label [[CONT60:%.*]], label [[TRAP59:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap59: +// CHECK: [[CONT58]]: +// CHECK-NEXT: br i1 true, label %[[CONT60:.*]], label %[[TRAP59:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP59]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont60: +// CHECK: [[CONT60]]: // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP61]], ptr align 8 [[AGG_TEMP14]], i64 24, i1 false) // CHECK-NEXT: [[WIDE_PTR_PTR_ADDR62:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP61]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR63:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR62]], align 8 diff --git a/clang/test/BoundsSafety/CodeGen/ended_by_assign_checks_seq-O2.c b/clang/test/BoundsSafety/CodeGen/ended_by_assign_checks_seq-O2.c index 67a4f55ee2ee2..f6d0d9d2e87a7 100644 --- a/clang/test/BoundsSafety/CodeGen/ended_by_assign_checks_seq-O2.c +++ b/clang/test/BoundsSafety/CodeGen/ended_by_assign_checks_seq-O2.c @@ -68,7 +68,7 @@ void TestRangeOK4(void) { // CHECK-NEXT: [[CMP80_NOT:%.*]] = icmp ugt ptr [[BOUND_PTR_ARITH60]], [[BOUND_PTR_ARITH8]], {{!annotation ![0-9]+}} // CHECK-NEXT: [[CMP95_NOT:%.*]] = icmp ugt ptr [[ARR]], [[BOUND_PTR_ARITH60]], {{!annotation ![0-9]+}} // CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[CMP80_NOT]], [[CMP95_NOT]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[OR_COND]], label %[[TRAP:.*]], label %[[CONT96:.*]], {{!prof ![0-9]+}}, {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[OR_COND]], label %[[TRAP:.*]], label %[[CONT96:.*]], {{!annotation ![0-9]+}} // CHECK: [[TRAP]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR7:[0-9]+]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} diff --git a/clang/test/BoundsSafety/CodeGen/ended_by_assign_checks_seq.c b/clang/test/BoundsSafety/CodeGen/ended_by_assign_checks_seq.c index fe98fd0c2055e..9e9306c9a5a5b 100644 --- a/clang/test/BoundsSafety/CodeGen/ended_by_assign_checks_seq.c +++ b/clang/test/BoundsSafety/CodeGen/ended_by_assign_checks_seq.c @@ -27,12 +27,9 @@ void foo(void); // CHECK-NEXT: [[AGG_TEMP34:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP42:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP50:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-NEXT: [[AGG_TEMP51:%.*]] = alloca [[STRUCT_S]], align 8 // CHECK-NEXT: [[AGG_TEMP55:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[TMP_TMP56:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-NEXT: [[AGG_TEMP57:%.*]] = alloca [[STRUCT_S]], align 8 // CHECK-NEXT: [[AGG_TEMP62:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-NEXT: [[AGG_TEMP63:%.*]] = alloca [[STRUCT_S]], align 8 // CHECK-NEXT: [[AGG_TEMP67:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP74:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP82:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 @@ -156,8 +153,7 @@ void foo(void); // CHECK-NEXT: [[END49:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 1 // CHECK-NEXT: store ptr [[WIDE_PTR_PTR44]], ptr [[END49]], align 8 // CHECK-NEXT: call void @foo() -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP51]], ptr align 8 [[S]], i64 24, i1 false) -// CHECK-NEXT: [[ITER52:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP51]], i32 0, i32 0 +// CHECK-NEXT: [[ITER52:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 0 // CHECK-NEXT: [[TMP27:%.*]] = load ptr, ptr [[ITER52]], align 8 // CHECK-NEXT: [[START53:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 2 // CHECK-NEXT: [[TMP28:%.*]] = load ptr, ptr [[START53]], align 8 @@ -169,10 +165,9 @@ void foo(void); // CHECK-NEXT: store ptr [[TMP27]], ptr [[TMP31]], align 8 // CHECK-NEXT: [[TMP32:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP50]], i32 0, i32 2 // CHECK-NEXT: store ptr [[TMP29]], ptr [[TMP32]], align 8 -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP57]], ptr align 8 [[S]], i64 24, i1 false) -// CHECK-NEXT: [[START58:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP57]], i32 0, i32 2 +// CHECK-NEXT: [[START58:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 2 // CHECK-NEXT: [[TMP33:%.*]] = load ptr, ptr [[START58]], align 8 -// CHECK-NEXT: [[END59:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP57]], i32 0, i32 1 +// CHECK-NEXT: [[END59:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 1 // CHECK-NEXT: [[TMP34:%.*]] = load ptr, ptr [[END59]], align 8 // CHECK-NEXT: [[ITER60:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 0 // CHECK-NEXT: [[TMP35:%.*]] = load ptr, ptr [[ITER60]], align 8 @@ -195,8 +190,7 @@ void foo(void); // CHECK-NEXT: [[TMP46:%.*]] = load ptr, ptr [[TMP45]], align 8 // CHECK-NEXT: [[TMP47:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP55]], i32 0, i32 2 // CHECK-NEXT: store ptr [[TMP46]], ptr [[TMP47]], align 8 -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP63]], ptr align 8 [[S]], i64 24, i1 false) -// CHECK-NEXT: [[ITER64:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP63]], i32 0, i32 0 +// CHECK-NEXT: [[ITER64:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 0 // CHECK-NEXT: [[TMP48:%.*]] = load ptr, ptr [[ITER64]], align 8 // CHECK-NEXT: [[END65:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 1 // CHECK-NEXT: [[TMP49:%.*]] = load ptr, ptr [[END65]], align 8 @@ -243,11 +237,11 @@ void foo(void); // CHECK-NEXT: br label [[LAND_END]], {{!annotation ![0-9]+}} // CHECK: land.end: // CHECK-NEXT: [[TMP54:%.*]] = phi i1 [ false, [[CONT25]] ], [ [[CMP96]], [[LAND_RHS]] ], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP54]], label [[CONT98:%.*]], label [[TRAP97:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap97: +// CHECK-NEXT: br i1 [[TMP54]], label %[[CONT98:.*]], label %[[TRAP97:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP97]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont98: +// CHECK: [[CONT98]]: // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP99]], ptr align 8 [[AGG_TEMP50]], i64 24, i1 false) // CHECK-NEXT: [[WIDE_PTR_PTR_ADDR100:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP99]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR101:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR100]], align 8 diff --git a/clang/test/BoundsSafety/CodeGen/ended_by_bag_of_bytes.c b/clang/test/BoundsSafety/CodeGen/ended_by_bag_of_bytes.c index 50b1cd7ed7469..ce40d61903b7f 100644 --- a/clang/test/BoundsSafety/CodeGen/ended_by_bag_of_bytes.c +++ b/clang/test/BoundsSafety/CodeGen/ended_by_bag_of_bytes.c @@ -18,11 +18,8 @@ struct T { // CHECK-NEXT: entry: // CHECK-NEXT: [[T:%.*]] = alloca [[STRUCT_T:%.*]], align 8 // CHECK-NEXT: [[AGG_TEMP:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-NEXT: [[AGG_TEMP1:%.*]] = alloca [[STRUCT_S:%.*]], align 8 // CHECK-NEXT: [[AGG_TEMP3:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-NEXT: [[AGG_TEMP4:%.*]] = alloca [[STRUCT_T]], align 8 // CHECK-NEXT: [[AGG_TEMP5:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-NEXT: [[AGG_TEMP6:%.*]] = alloca [[STRUCT_S]], align 8 // CHECK-NEXT: [[AGG_TEMP9:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP10:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP17:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 @@ -34,8 +31,7 @@ struct T { // CHECK-NEXT: store i32 [[T_COERCE0:%.*]], ptr [[TMP0]], align 8 // CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds { i32, ptr }, ptr [[T]], i32 0, i32 1 // CHECK-NEXT: store ptr [[T_COERCE1:%.*]], ptr [[TMP1]], align 8 -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP1]], ptr align 8 [[S:%.*]], i64 24, i1 false) -// CHECK-NEXT: [[ITER:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP1]], i32 0, i32 0 +// CHECK-NEXT: [[ITER:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], ptr [[S:%.*]], i32 0, i32 0 // CHECK-NEXT: [[TMP2:%.*]] = load ptr, ptr [[ITER]], align 8 // CHECK-NEXT: [[START:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 2 // CHECK-NEXT: [[TMP3:%.*]] = load ptr, ptr [[START]], align 8 @@ -47,10 +43,9 @@ struct T { // CHECK-NEXT: store ptr [[TMP2]], ptr [[TMP6]], align 8 // CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP]], i32 0, i32 2 // CHECK-NEXT: store ptr [[TMP4]], ptr [[TMP7]], align 8 -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP4]], ptr align 8 [[T]], i64 16, i1 false) -// CHECK-NEXT: [[CNT:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[AGG_TEMP4]], i32 0, i32 0 +// CHECK-NEXT: [[CNT:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[T]], i32 0, i32 0 // CHECK-NEXT: [[TMP8:%.*]] = load i32, ptr [[CNT]], align 8 -// CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[AGG_TEMP4]], i32 0, i32 1 +// CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[T]], i32 0, i32 1 // CHECK-NEXT: [[TMP9:%.*]] = load ptr, ptr [[PTR]], align 8 // CHECK-NEXT: [[IDX_EXT:%.*]] = sext i32 [[TMP8]] to i64 // CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr [[TMP9]], i64 [[IDX_EXT]] @@ -60,8 +55,7 @@ struct T { // CHECK-NEXT: store ptr [[ADD_PTR]], ptr [[TMP11]], align 8 // CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 2 // CHECK-NEXT: store ptr [[TMP9]], ptr [[TMP12]], align 8 -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP6]], ptr align 8 [[S]], i64 24, i1 false) -// CHECK-NEXT: [[ITER7:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[AGG_TEMP6]], i32 0, i32 0 +// CHECK-NEXT: [[ITER7:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 0 // CHECK-NEXT: [[TMP13:%.*]] = load ptr, ptr [[ITER7]], align 8 // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[S]], i32 0, i32 1 // CHECK-NEXT: [[TMP14:%.*]] = load ptr, ptr [[END]], align 8 diff --git a/clang/test/BoundsSafety/CodeGen/flexible-array-member-bidi-O0.c b/clang/test/BoundsSafety/CodeGen/flexible-array-member-bidi-O0.c index e9667bbaf80cc..e6c66bdf7fafb 100644 --- a/clang/test/BoundsSafety/CodeGen/flexible-array-member-bidi-O0.c +++ b/clang/test/BoundsSafety/CodeGen/flexible-array-member-bidi-O0.c @@ -968,7 +968,6 @@ void shared_flexbase_self_assign_reverse(struct Shared * __bidi_indexable p) { // CHECK-NEXT: [[AGG_TEMP:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.1", align 8 // CHECK-NEXT: [[AGG_TEMP1:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 // CHECK-NEXT: [[AGG_TEMP2:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 -// CHECK-NEXT: [[AGG_TEMP5:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 // CHECK-NEXT: [[AGG_TEMP16:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.1", align 8 // CHECK-NEXT: [[AGG_TEMP23:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.1", align 8 // CHECK-NEXT: [[AGG_TEMP26:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.1", align 8 @@ -981,12 +980,11 @@ void shared_flexbase_self_assign_reverse(struct Shared * __bidi_indexable p) { // CHECK-NEXT: store ptr [[P]], ptr [[P_INDIRECT_ADDR]], align 8 // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[P]], ptr align 8 [[P]], i64 24, i1 false) // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP1]], ptr align 8 [[P]], i64 24, i1 false) -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP2]], ptr align 8 [[AGG_TEMP1]], i64 24, i1 false) -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP1]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP1]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP1]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR]], align 8 // CHECK-NEXT: [[TMP0:%.*]] = getelementptr [[STRUCT_SHARED:%.*]], ptr [[WIDE_PTR_PTR]], i64 1 // CHECK-NEXT: [[TMP1:%.*]] = icmp ule ptr [[TMP0]], [[WIDE_PTR_UB]], !annotation [[META2]] @@ -1003,12 +1001,12 @@ void shared_flexbase_self_assign_reverse(struct Shared * __bidi_indexable p) { // CHECK: [[CONT4]]: // CHECK-NEXT: [[LEN:%.*]] = getelementptr inbounds [[STRUCT_SHARED]], ptr [[WIDE_PTR_PTR]], i32 0, i32 0 // CHECK-NEXT: [[TMP3:%.*]] = load i32, ptr [[LEN]], align 8 -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP5]], ptr align 8 [[AGG_TEMP1]], i64 24, i1 false) -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR6:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP5]], i32 0, i32 0 +// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP2]], ptr align 8 [[P]], i64 24, i1 false) +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR6:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR7:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR6]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR8:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP5]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR8:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB9:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR8]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR10:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP5]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR10:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB11:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR10]], align 8 // CHECK-NEXT: [[TMP4:%.*]] = getelementptr [[STRUCT_SHARED]], ptr [[WIDE_PTR_PTR7]], i64 1 // CHECK-NEXT: [[TMP5:%.*]] = icmp ule ptr [[TMP4]], [[WIDE_PTR_UB9]], !annotation [[META2]] @@ -1153,7 +1151,6 @@ void shared_flexbase_self_assign_fr(struct Shared * __bidi_indexable p) { // CHECK-NEXT: [[AGG_TEMP:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.1", align 8 // CHECK-NEXT: [[AGG_TEMP1:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 // CHECK-NEXT: [[AGG_TEMP2:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 -// CHECK-NEXT: [[AGG_TEMP5:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 // CHECK-NEXT: [[AGG_TEMP16:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.1", align 8 // CHECK-NEXT: [[AGG_TEMP23:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.1", align 8 // CHECK-NEXT: [[AGG_TEMP26:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.1", align 8 @@ -1166,12 +1163,11 @@ void shared_flexbase_self_assign_fr(struct Shared * __bidi_indexable p) { // CHECK-NEXT: store ptr [[P]], ptr [[P_INDIRECT_ADDR]], align 8 // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[P]], ptr align 8 [[P]], i64 24, i1 false) // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP1]], ptr align 8 [[P]], i64 24, i1 false) -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP2]], ptr align 8 [[AGG_TEMP1]], i64 24, i1 false) -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP1]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP1]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP1]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR]], align 8 // CHECK-NEXT: [[TMP0:%.*]] = getelementptr [[STRUCT_SHARED:%.*]], ptr [[WIDE_PTR_PTR]], i64 1 // CHECK-NEXT: [[TMP1:%.*]] = icmp ule ptr [[TMP0]], [[WIDE_PTR_UB]], !annotation [[META2]] @@ -1188,12 +1184,12 @@ void shared_flexbase_self_assign_fr(struct Shared * __bidi_indexable p) { // CHECK: [[CONT4]]: // CHECK-NEXT: [[LEN:%.*]] = getelementptr inbounds [[STRUCT_SHARED]], ptr [[WIDE_PTR_PTR]], i32 0, i32 0 // CHECK-NEXT: [[TMP3:%.*]] = load i32, ptr [[LEN]], align 8 -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP5]], ptr align 8 [[AGG_TEMP1]], i64 24, i1 false) -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR6:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP5]], i32 0, i32 0 +// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP2]], ptr align 8 [[P]], i64 24, i1 false) +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR6:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR7:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR6]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR8:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP5]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR8:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB9:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR8]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR10:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP5]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR10:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP2]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB11:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR10]], align 8 // CHECK-NEXT: [[TMP4:%.*]] = getelementptr [[STRUCT_SHARED]], ptr [[WIDE_PTR_PTR7]], i64 1 // CHECK-NEXT: [[TMP5:%.*]] = icmp ule ptr [[TMP4]], [[WIDE_PTR_UB9]], !annotation [[META2]] diff --git a/clang/test/BoundsSafety/CodeGen/flexible-array-member-promotion-call-builtin-O2.c b/clang/test/BoundsSafety/CodeGen/flexible-array-member-promotion-call-builtin-O2.c index a43e70502d7c5..5ba80cefb692e 100644 --- a/clang/test/BoundsSafety/CodeGen/flexible-array-member-promotion-call-builtin-O2.c +++ b/clang/test/BoundsSafety/CodeGen/flexible-array-member-promotion-call-builtin-O2.c @@ -20,25 +20,25 @@ typedef struct { // CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr [[ELEMS]], i64 [[IDX_EXT]] // CHECK-NEXT: br label [[BOUNDSCHECK_CONT]] // CHECK: boundscheck.cont: -// CHECK-NEXT: [[AGG_TEMP2_SROA_3_0:%.*]] = phi ptr [ [[ADD_PTR]], [[BOUNDSCHECK_NOTNULL]] ], [ null, [[ENTRY:%.*]] ] +// CHECK-NEXT: [[AGG_TEMP1_SROA_3_0:%.*]] = phi ptr [ [[ADD_PTR]], [[BOUNDSCHECK_NOTNULL]] ], [ null, [[ENTRY:%.*]] ] // CHECK-NEXT: [[CONV:%.*]] = zext i32 [[SIZE:%.*]] to i64 -// CHECK-NEXT: [[CMP_NOT:%.*]] = icmp ult ptr [[AGG_TEMP2_SROA_3_0]], [[FLEX]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[SUB_PTR_LHS_CAST:%.*]] = ptrtoint ptr [[AGG_TEMP2_SROA_3_0]] to i64, {{!annotation ![0-9]+}} +// CHECK-NEXT: [[CMP_NOT:%.*]] = icmp ult ptr [[AGG_TEMP1_SROA_3_0]], [[FLEX]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[SUB_PTR_LHS_CAST:%.*]] = ptrtoint ptr [[AGG_TEMP1_SROA_3_0]] to i64, {{!annotation ![0-9]+}} // CHECK-NEXT: [[SUB_PTR_RHS_CAST:%.*]] = ptrtoint ptr [[FLEX]] to i64, {{!annotation ![0-9]+}} // CHECK-NEXT: [[SUB_PTR_SUB:%.*]] = sub i64 [[SUB_PTR_LHS_CAST]], [[SUB_PTR_RHS_CAST]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[CMP68_NOT:%.*]] = icmp ult i64 [[SUB_PTR_SUB]], [[CONV]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[CMP_NOT]], [[CMP68_NOT]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[CMP67_NOT:%.*]] = icmp ult i64 [[SUB_PTR_SUB]], [[CONV]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[CMP_NOT]], [[CMP67_NOT]], {{!annotation ![0-9]+}} // CHECK-NEXT: br i1 [[OR_COND]], label [[TRAP:%.*]], label [[CONT:%.*]], {{!annotation ![0-9]+}} // CHECK: trap: // CHECK-NEXT: tail call void @llvm.ubsantrap(i8 25) #[[ATTR4:[0-9]+]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} // CHECK: cont: // CHECK-NEXT: tail call void @llvm.memset.p0.i64(ptr align 1 [[FLEX]], i8 0, i64 [[CONV]], i1 false) -// CHECK-NEXT: [[DOTNOT89:%.*]] = icmp ne ptr [[FLEX]], null, {{!annotation ![0-9]+}} -// CHECK-NEXT: [[DOTNOT90:%.*]] = icmp eq i32 [[SIZE]], 0, {{!annotation ![0-9]+}} -// CHECK-NEXT: [[OR_COND91:%.*]] = and i1 [[DOTNOT89]], [[DOTNOT90]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[OR_COND91]], label [[TRAP]], label [[CONT88:%.*]], {{!annotation ![0-9]+}} -// CHECK: cont88: +// CHECK-NEXT: [[DOTNOT88:%.*]] = icmp ne ptr [[FLEX]], null, {{!annotation ![0-9]+}} +// CHECK-NEXT: [[DOTNOT89:%.*]] = icmp eq i32 [[SIZE]], 0, {{!annotation ![0-9]+}} +// CHECK-NEXT: [[OR_COND90:%.*]] = and i1 [[DOTNOT88]], [[DOTNOT89]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[OR_COND90]], label [[TRAP]], label [[CONT87:%.*]], {{!annotation ![0-9]+}} +// CHECK: cont87: // CHECK-NEXT: ret ptr [[FLEX]] // void *set(flex_t *flex, unsigned size) { @@ -56,42 +56,42 @@ void *set(flex_t *flex, unsigned size) { // CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr [[ELEMS]], i64 [[IDX_EXT]] // CHECK-NEXT: br label [[BOUNDSCHECK_CONT]] // CHECK: boundscheck.cont: -// CHECK-NEXT: [[AGG_TEMP2_SROA_3_0:%.*]] = phi ptr [ [[ADD_PTR]], [[BOUNDSCHECK_NOTNULL]] ], [ null, [[ENTRY:%.*]] ] -// CHECK-NEXT: [[DOTNOT188:%.*]] = icmp eq ptr [[SRC:%.*]], null, {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[DOTNOT188]], label [[BOUNDSCHECK_CONT12:%.*]], label [[BOUNDSCHECK_NOTNULL5:%.*]], {{!annotation ![0-9]+}} -// CHECK: boundscheck.notnull5: -// CHECK-NEXT: [[ELEMS6:%.*]] = getelementptr inbounds i8, ptr [[SRC]], i64 4 +// CHECK-NEXT: [[AGG_TEMP1_SROA_3_0:%.*]] = phi ptr [ [[ADD_PTR]], [[BOUNDSCHECK_NOTNULL]] ], [ null, [[ENTRY:%.*]] ] +// CHECK-NEXT: [[DOTNOT187:%.*]] = icmp eq ptr [[SRC:%.*]], null, {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[DOTNOT187]], label [[BOUNDSCHECK_CONT11:%.*]], label [[BOUNDSCHECK_NOTNULL4:%.*]], {{!annotation ![0-9]+}} +// CHECK: boundscheck.notnull4: +// CHECK-NEXT: [[ELEMS5:%.*]] = getelementptr inbounds i8, ptr [[SRC]], i64 4 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[SRC]], align 4, {{!tbaa ![0-9]+}} -// CHECK-NEXT: [[IDX_EXT9:%.*]] = sext i32 [[TMP1]] to i64 -// CHECK-NEXT: [[ADD_PTR10:%.*]] = getelementptr inbounds i32, ptr [[ELEMS6]], i64 [[IDX_EXT9]] -// CHECK-NEXT: br label [[BOUNDSCHECK_CONT12]] -// CHECK: boundscheck.cont12: -// CHECK-NEXT: [[AGG_TEMP4_SROA_3_0:%.*]] = phi ptr [ [[ADD_PTR10]], [[BOUNDSCHECK_NOTNULL5]] ], [ null, [[BOUNDSCHECK_CONT]] ] +// CHECK-NEXT: [[IDX_EXT8:%.*]] = sext i32 [[TMP1]] to i64 +// CHECK-NEXT: [[ADD_PTR9:%.*]] = getelementptr inbounds i32, ptr [[ELEMS5]], i64 [[IDX_EXT8]] +// CHECK-NEXT: br label [[BOUNDSCHECK_CONT11]] +// CHECK: boundscheck.cont11: +// CHECK-NEXT: [[AGG_TEMP3_SROA_3_0:%.*]] = phi ptr [ [[ADD_PTR9]], [[BOUNDSCHECK_NOTNULL4]] ], [ null, [[BOUNDSCHECK_CONT]] ] // CHECK-NEXT: [[CONV:%.*]] = zext i32 [[SIZE:%.*]] to i64 -// CHECK-NEXT: [[CMP_NOT:%.*]] = icmp ult ptr [[AGG_TEMP4_SROA_3_0]], [[SRC]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[SUB_PTR_LHS_CAST:%.*]] = ptrtoint ptr [[AGG_TEMP4_SROA_3_0]] to i64, {{!annotation ![0-9]+}} +// CHECK-NEXT: [[CMP_NOT:%.*]] = icmp ult ptr [[AGG_TEMP3_SROA_3_0]], [[SRC]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[SUB_PTR_LHS_CAST:%.*]] = ptrtoint ptr [[AGG_TEMP3_SROA_3_0]] to i64, {{!annotation ![0-9]+}} // CHECK-NEXT: [[SUB_PTR_RHS_CAST:%.*]] = ptrtoint ptr [[SRC]] to i64, {{!annotation ![0-9]+}} // CHECK-NEXT: [[SUB_PTR_SUB:%.*]] = sub i64 [[SUB_PTR_LHS_CAST]], [[SUB_PTR_RHS_CAST]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[CMP84_NOT:%.*]] = icmp ult i64 [[SUB_PTR_SUB]], [[CONV]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[CMP_NOT]], [[CMP84_NOT]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[CMP102_NOT:%.*]] = icmp ult ptr [[AGG_TEMP2_SROA_3_0]], [[DEST]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[OR_COND191:%.*]] = select i1 [[OR_COND]], i1 true, i1 [[CMP102_NOT]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[SUB_PTR_LHS_CAST154:%.*]] = ptrtoint ptr [[AGG_TEMP2_SROA_3_0]] to i64, {{!annotation ![0-9]+}} -// CHECK-NEXT: [[SUB_PTR_RHS_CAST155:%.*]] = ptrtoint ptr [[DEST]] to i64, {{!annotation ![0-9]+}} -// CHECK-NEXT: [[SUB_PTR_SUB156:%.*]] = sub i64 [[SUB_PTR_LHS_CAST154]], [[SUB_PTR_RHS_CAST155]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[CMP157_NOT:%.*]] = icmp ult i64 [[SUB_PTR_SUB156]], [[CONV]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[OR_COND192:%.*]] = select i1 [[OR_COND191]], i1 true, i1 [[CMP157_NOT]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[OR_COND192]], label [[TRAP:%.*]], label [[CONT160:%.*]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[CMP83_NOT:%.*]] = icmp ult i64 [[SUB_PTR_SUB]], [[CONV]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[CMP_NOT]], [[CMP83_NOT]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[CMP101_NOT:%.*]] = icmp ult ptr [[AGG_TEMP1_SROA_3_0]], [[DEST]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[OR_COND190:%.*]] = select i1 [[OR_COND]], i1 true, i1 [[CMP101_NOT]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[SUB_PTR_LHS_CAST153:%.*]] = ptrtoint ptr [[AGG_TEMP1_SROA_3_0]] to i64, {{!annotation ![0-9]+}} +// CHECK-NEXT: [[SUB_PTR_RHS_CAST154:%.*]] = ptrtoint ptr [[DEST]] to i64, {{!annotation ![0-9]+}} +// CHECK-NEXT: [[SUB_PTR_SUB155:%.*]] = sub i64 [[SUB_PTR_LHS_CAST153]], [[SUB_PTR_RHS_CAST154]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[CMP156_NOT:%.*]] = icmp ult i64 [[SUB_PTR_SUB155]], [[CONV]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[OR_COND191:%.*]] = select i1 [[OR_COND190]], i1 true, i1 [[CMP156_NOT]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[OR_COND191]], label [[TRAP:%.*]], label [[CONT159:%.*]], {{!annotation ![0-9]+}} // CHECK: trap: // CHECK-NEXT: tail call void @llvm.ubsantrap(i8 25) #[[ATTR4]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont160: +// CHECK: cont159: // CHECK-NEXT: tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 [[DEST]], ptr align 1 [[SRC]], i64 [[CONV]], i1 false) -// CHECK-NEXT: [[DOTNOT189:%.*]] = icmp ne ptr [[DEST]], null, {{!annotation ![0-9]+}} -// CHECK-NEXT: [[DOTNOT190:%.*]] = icmp eq i32 [[SIZE]], 0, {{!annotation ![0-9]+}} -// CHECK-NEXT: [[OR_COND193:%.*]] = and i1 [[DOTNOT189]], [[DOTNOT190]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[OR_COND193]], label [[TRAP]], label [[CONT186:%.*]], {{!annotation ![0-9]+}} -// CHECK: cont186: +// CHECK-NEXT: [[DOTNOT188:%.*]] = icmp ne ptr [[DEST]], null, {{!annotation ![0-9]+}} +// CHECK-NEXT: [[DOTNOT189:%.*]] = icmp eq i32 [[SIZE]], 0, {{!annotation ![0-9]+}} +// CHECK-NEXT: [[OR_COND192:%.*]] = and i1 [[DOTNOT188]], [[DOTNOT189]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[OR_COND192]], label [[TRAP]], label [[CONT185:%.*]], {{!annotation ![0-9]+}} +// CHECK: cont185: // CHECK-NEXT: ret ptr [[DEST]] // void *cpy(flex_t *dest, const flex_t *src, unsigned size) { @@ -158,42 +158,42 @@ void *__unsafe_indexable pcpy(flex_t *dest, const flex_t *src, unsigned size) { // CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr [[ELEMS]], i64 [[IDX_EXT]] // CHECK-NEXT: br label [[BOUNDSCHECK_CONT]] // CHECK: boundscheck.cont: -// CHECK-NEXT: [[AGG_TEMP2_SROA_3_0:%.*]] = phi ptr [ [[ADD_PTR]], [[BOUNDSCHECK_NOTNULL]] ], [ null, [[ENTRY:%.*]] ] -// CHECK-NEXT: [[DOTNOT188:%.*]] = icmp eq ptr [[SRC:%.*]], null, {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[DOTNOT188]], label [[BOUNDSCHECK_CONT12:%.*]], label [[BOUNDSCHECK_NOTNULL5:%.*]], {{!annotation ![0-9]+}} -// CHECK: boundscheck.notnull5: -// CHECK-NEXT: [[ELEMS6:%.*]] = getelementptr inbounds i8, ptr [[SRC]], i64 4 +// CHECK-NEXT: [[AGG_TEMP1_SROA_3_0:%.*]] = phi ptr [ [[ADD_PTR]], [[BOUNDSCHECK_NOTNULL]] ], [ null, [[ENTRY:%.*]] ] +// CHECK-NEXT: [[DOTNOT187:%.*]] = icmp eq ptr [[SRC:%.*]], null, {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[DOTNOT187]], label [[BOUNDSCHECK_CONT11:%.*]], label [[BOUNDSCHECK_NOTNULL4:%.*]], {{!annotation ![0-9]+}} +// CHECK: boundscheck.notnull4: +// CHECK-NEXT: [[ELEMS5:%.*]] = getelementptr inbounds i8, ptr [[SRC]], i64 4 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[SRC]], align 4, {{!tbaa ![0-9]+}} -// CHECK-NEXT: [[IDX_EXT9:%.*]] = sext i32 [[TMP1]] to i64 -// CHECK-NEXT: [[ADD_PTR10:%.*]] = getelementptr inbounds i32, ptr [[ELEMS6]], i64 [[IDX_EXT9]] -// CHECK-NEXT: br label [[BOUNDSCHECK_CONT12]] -// CHECK: boundscheck.cont12: -// CHECK-NEXT: [[AGG_TEMP4_SROA_3_0:%.*]] = phi ptr [ [[ADD_PTR10]], [[BOUNDSCHECK_NOTNULL5]] ], [ null, [[BOUNDSCHECK_CONT]] ] +// CHECK-NEXT: [[IDX_EXT8:%.*]] = sext i32 [[TMP1]] to i64 +// CHECK-NEXT: [[ADD_PTR9:%.*]] = getelementptr inbounds i32, ptr [[ELEMS5]], i64 [[IDX_EXT8]] +// CHECK-NEXT: br label [[BOUNDSCHECK_CONT11]] +// CHECK: boundscheck.cont11: +// CHECK-NEXT: [[AGG_TEMP3_SROA_3_0:%.*]] = phi ptr [ [[ADD_PTR9]], [[BOUNDSCHECK_NOTNULL4]] ], [ null, [[BOUNDSCHECK_CONT]] ] // CHECK-NEXT: [[CONV:%.*]] = zext i32 [[SIZE:%.*]] to i64 -// CHECK-NEXT: [[CMP_NOT:%.*]] = icmp ult ptr [[AGG_TEMP4_SROA_3_0]], [[SRC]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[SUB_PTR_LHS_CAST:%.*]] = ptrtoint ptr [[AGG_TEMP4_SROA_3_0]] to i64, {{!annotation ![0-9]+}} +// CHECK-NEXT: [[CMP_NOT:%.*]] = icmp ult ptr [[AGG_TEMP3_SROA_3_0]], [[SRC]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[SUB_PTR_LHS_CAST:%.*]] = ptrtoint ptr [[AGG_TEMP3_SROA_3_0]] to i64, {{!annotation ![0-9]+}} // CHECK-NEXT: [[SUB_PTR_RHS_CAST:%.*]] = ptrtoint ptr [[SRC]] to i64, {{!annotation ![0-9]+}} // CHECK-NEXT: [[SUB_PTR_SUB:%.*]] = sub i64 [[SUB_PTR_LHS_CAST]], [[SUB_PTR_RHS_CAST]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[CMP84_NOT:%.*]] = icmp ult i64 [[SUB_PTR_SUB]], [[CONV]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[CMP_NOT]], [[CMP84_NOT]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[CMP102_NOT:%.*]] = icmp ult ptr [[AGG_TEMP2_SROA_3_0]], [[DEST]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[OR_COND191:%.*]] = select i1 [[OR_COND]], i1 true, i1 [[CMP102_NOT]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[SUB_PTR_LHS_CAST154:%.*]] = ptrtoint ptr [[AGG_TEMP2_SROA_3_0]] to i64, {{!annotation ![0-9]+}} -// CHECK-NEXT: [[SUB_PTR_RHS_CAST155:%.*]] = ptrtoint ptr [[DEST]] to i64, {{!annotation ![0-9]+}} -// CHECK-NEXT: [[SUB_PTR_SUB156:%.*]] = sub i64 [[SUB_PTR_LHS_CAST154]], [[SUB_PTR_RHS_CAST155]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[CMP157_NOT:%.*]] = icmp ult i64 [[SUB_PTR_SUB156]], [[CONV]], {{!annotation ![0-9]+}} -// CHECK-NEXT: [[OR_COND192:%.*]] = select i1 [[OR_COND191]], i1 true, i1 [[CMP157_NOT]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[OR_COND192]], label [[TRAP:%.*]], label [[CONT160:%.*]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[CMP83_NOT:%.*]] = icmp ult i64 [[SUB_PTR_SUB]], [[CONV]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[CMP_NOT]], [[CMP83_NOT]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[CMP101_NOT:%.*]] = icmp ult ptr [[AGG_TEMP1_SROA_3_0]], [[DEST]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[OR_COND190:%.*]] = select i1 [[OR_COND]], i1 true, i1 [[CMP101_NOT]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[SUB_PTR_LHS_CAST153:%.*]] = ptrtoint ptr [[AGG_TEMP1_SROA_3_0]] to i64, {{!annotation ![0-9]+}} +// CHECK-NEXT: [[SUB_PTR_RHS_CAST154:%.*]] = ptrtoint ptr [[DEST]] to i64, {{!annotation ![0-9]+}} +// CHECK-NEXT: [[SUB_PTR_SUB155:%.*]] = sub i64 [[SUB_PTR_LHS_CAST153]], [[SUB_PTR_RHS_CAST154]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[CMP156_NOT:%.*]] = icmp ult i64 [[SUB_PTR_SUB155]], [[CONV]], {{!annotation ![0-9]+}} +// CHECK-NEXT: [[OR_COND191:%.*]] = select i1 [[OR_COND190]], i1 true, i1 [[CMP156_NOT]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[OR_COND191]], label [[TRAP:%.*]], label [[CONT159:%.*]], {{!annotation ![0-9]+}} // CHECK: trap: // CHECK-NEXT: tail call void @llvm.ubsantrap(i8 25) #[[ATTR4]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont160: +// CHECK: cont159: // CHECK-NEXT: tail call void @llvm.memmove.p0.p0.i64(ptr align 1 [[DEST]], ptr align 1 [[SRC]], i64 [[CONV]], i1 false) -// CHECK-NEXT: [[DOTNOT189:%.*]] = icmp ne ptr [[DEST]], null, {{!annotation ![0-9]+}} -// CHECK-NEXT: [[DOTNOT190:%.*]] = icmp eq i32 [[SIZE]], 0, {{!annotation ![0-9]+}} -// CHECK-NEXT: [[OR_COND193:%.*]] = and i1 [[DOTNOT189]], [[DOTNOT190]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[OR_COND193]], label [[TRAP]], label [[CONT186:%.*]], {{!annotation ![0-9]+}} -// CHECK: cont186: +// CHECK-NEXT: [[DOTNOT188:%.*]] = icmp ne ptr [[DEST]], null, {{!annotation ![0-9]+}} +// CHECK-NEXT: [[DOTNOT189:%.*]] = icmp eq i32 [[SIZE]], 0, {{!annotation ![0-9]+}} +// CHECK-NEXT: [[OR_COND192:%.*]] = and i1 [[DOTNOT188]], [[DOTNOT189]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[OR_COND192]], label [[TRAP]], label [[CONT185:%.*]], {{!annotation ![0-9]+}} +// CHECK: cont185: // CHECK-NEXT: ret ptr [[DEST]] // void *move(flex_t *dest, const flex_t *src, unsigned size) { diff --git a/clang/test/BoundsSafety/CodeGen/flexible-array-member-promotion-deref.c b/clang/test/BoundsSafety/CodeGen/flexible-array-member-promotion-deref.c index a354a91b88eda..01a2c98805a94 100644 --- a/clang/test/BoundsSafety/CodeGen/flexible-array-member-promotion-deref.c +++ b/clang/test/BoundsSafety/CodeGen/flexible-array-member-promotion-deref.c @@ -35,7 +35,7 @@ flex_t g_flex = {2, {1, 2}}; // CHECK-NEXT: [[WIDE_PTR_LB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP2]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR]], align 8 // CHECK-NEXT: [[FLEX_BASE_NULL_CHECK:%.*]] = icmp ne ptr [[WIDE_PTR_PTR]], null, {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[FLEX_BASE_NULL_CHECK]], label [[FLEX_BASE_NONNULL:%.*]], label [[CONT32:%.*]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[FLEX_BASE_NULL_CHECK]], label [[FLEX_BASE_NONNULL:%.*]], label %[[CONT32:.*]], {{!annotation ![0-9]+}} // CHECK: flex.base.nonnull: // CHECK-NEXT: [[TMP4:%.*]] = getelementptr [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR]], i64 1 // CHECK-NEXT: [[TMP5:%.*]] = icmp ule ptr [[WIDE_PTR_PTR]], [[TMP4]], {{!annotation ![0-9]+}} @@ -53,17 +53,17 @@ flex_t g_flex = {2, {1, 2}}; // CHECK-NEXT: [[WIDE_PTR_LB9:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR8]], align 8 // CHECK-NEXT: [[TMP6:%.*]] = getelementptr [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR5]], i64 1 // CHECK-NEXT: [[TMP7:%.*]] = icmp ule ptr [[TMP6]], [[WIDE_PTR_UB7]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP7]], label [[CONT11:%.*]], label [[TRAP10:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap10: +// CHECK-NEXT: br i1 [[TMP7]], label %[[CONT11:.*]], label %[[TRAP10:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP10]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont11: +// CHECK: [[CONT11]]: // CHECK-NEXT: [[TMP8:%.*]] = icmp ule ptr [[WIDE_PTR_LB9]], [[WIDE_PTR_PTR5]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP8]], label [[CONT13:%.*]], label [[TRAP12:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap12: +// CHECK-NEXT: br i1 [[TMP8]], label %[[CONT13:.*]], label %[[TRAP12:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP12]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont13: +// CHECK: [[CONT13]]: // CHECK-NEXT: [[ELEMS:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR5]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [0 x i32], ptr [[ELEMS]], i64 0, i64 0 // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP14]], ptr align 8 [[AGG_TEMP1]], i64 24, i1 false) @@ -75,48 +75,48 @@ flex_t g_flex = {2, {1, 2}}; // CHECK-NEXT: [[WIDE_PTR_LB20:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR19]], align 8 // CHECK-NEXT: [[TMP9:%.*]] = getelementptr [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR16]], i64 1 // CHECK-NEXT: [[TMP10:%.*]] = icmp ule ptr [[TMP9]], [[WIDE_PTR_UB18]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP10]], label [[CONT22:%.*]], label [[TRAP21:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap21: +// CHECK-NEXT: br i1 [[TMP10]], label %[[CONT22:.*]], label %[[TRAP21:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP21]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont22: +// CHECK: [[CONT22]]: // CHECK-NEXT: [[TMP11:%.*]] = icmp ule ptr [[WIDE_PTR_LB20]], [[WIDE_PTR_PTR16]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP11]], label [[CONT24:%.*]], label [[TRAP23:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap23: +// CHECK-NEXT: br i1 [[TMP11]], label %[[CONT24:.*]], label %[[TRAP23:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP23]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont24: +// CHECK: [[CONT24]]: // CHECK-NEXT: [[COUNT:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR16]], i32 0, i32 0 // CHECK-NEXT: [[TMP12:%.*]] = load i32, ptr [[COUNT]], align 4 // CHECK-NEXT: [[FLEX_COUNT_MINUS:%.*]] = icmp sle i32 0, [[TMP12]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[FLEX_COUNT_MINUS]], label [[CONT26:%.*]], label [[TRAP25:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap25: +// CHECK-NEXT: br i1 [[FLEX_COUNT_MINUS]], label %[[CONT26:.*]], label %[[TRAP25:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP25]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont26: +// CHECK: [[CONT26]]: // CHECK-NEXT: [[TMP13:%.*]] = icmp ule ptr [[ARRAYDECAY]], [[WIDE_PTR_UB]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP13]], label [[CONT28:%.*]], label [[TRAP27:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap27: +// CHECK-NEXT: br i1 [[TMP13]], label %[[CONT28:.*]], label %[[TRAP27:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP27]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont28: +// CHECK: [[CONT28]]: // CHECK-NEXT: [[TMP14:%.*]] = icmp uge ptr [[WIDE_PTR_PTR]], [[WIDE_PTR_LB]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP14]], label [[CONT30:%.*]], label [[TRAP29:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap29: +// CHECK-NEXT: br i1 [[TMP14]], label %[[CONT30:.*]], label %[[TRAP29:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP29]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont30: +// CHECK: [[CONT30]]: // CHECK-NEXT: [[UPPER_INTPTR:%.*]] = ptrtoint ptr [[WIDE_PTR_UB]] to i64, {{!annotation ![0-9]+}} // CHECK-NEXT: [[FAM_INTPTR:%.*]] = ptrtoint ptr [[ARRAYDECAY]] to i64, {{!annotation ![0-9]+}} // CHECK-NEXT: [[FLEX_AVAIL_COUNT:%.*]] = sub nuw i64 [[UPPER_INTPTR]], [[FAM_INTPTR]], {{!annotation ![0-9]+}} // CHECK-NEXT: [[FLEX_AVAIL_COUNT_DIV:%.*]] = sdiv exact i64 [[FLEX_AVAIL_COUNT]], 4, {{!annotation ![0-9]+}} // CHECK-NEXT: [[FLEX_COUNT_INTPTR:%.*]] = zext i32 [[TMP12]] to i64, {{!annotation ![0-9]+}} // CHECK-NEXT: [[FLEX_COUNT_CHECK:%.*]] = icmp ule i64 [[FLEX_COUNT_INTPTR]], [[FLEX_AVAIL_COUNT_DIV]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[FLEX_COUNT_CHECK]], label [[CONT32]], label [[TRAP31:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap31: +// CHECK-NEXT: br i1 [[FLEX_COUNT_CHECK]], label %[[CONT32]], label %[[TRAP31:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP31]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont32: +// CHECK: [[CONT32]]: // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP]], ptr align 8 [[AGG_TEMP1]], i64 24, i1 false) // CHECK-NEXT: [[WIDE_PTR_PTR_ADDR33:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR34:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR33]], align 8 @@ -125,27 +125,27 @@ flex_t g_flex = {2, {1, 2}}; // CHECK-NEXT: [[WIDE_PTR_LB_ADDR37:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB38:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR37]], align 8 // CHECK-NEXT: [[TMP15:%.*]] = icmp ne ptr [[WIDE_PTR_PTR34]], null, {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP15]], label [[BOUNDSCHECK_NOTNULL:%.*]], label [[CONT44:%.*]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[TMP15]], label [[BOUNDSCHECK_NOTNULL:%.*]], label %[[CONT44:.*]], {{!annotation ![0-9]+}} // CHECK: boundscheck.notnull: // CHECK-NEXT: [[TMP16:%.*]] = getelementptr [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR34]], i64 1, {{!annotation ![0-9]+}} // CHECK-NEXT: [[TMP17:%.*]] = icmp ule ptr [[TMP16]], [[WIDE_PTR_UB36]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP17]], label [[CONT40:%.*]], label [[TRAP39:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap39: +// CHECK-NEXT: br i1 [[TMP17]], label %[[CONT40:.*]], label %[[TRAP39:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP39]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont40: +// CHECK: [[CONT40]]: // CHECK-NEXT: [[TMP18:%.*]] = icmp ule ptr [[WIDE_PTR_PTR34]], [[TMP16]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP18]], label [[CONT42:%.*]], label [[TRAP41:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap41: +// CHECK-NEXT: br i1 [[TMP18]], label %[[CONT42:.*]], label %[[TRAP41:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP41]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont42: +// CHECK: [[CONT42]]: // CHECK-NEXT: [[TMP19:%.*]] = icmp uge ptr [[WIDE_PTR_PTR34]], [[WIDE_PTR_LB38]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP19]], label [[CONT44]], label [[TRAP43:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap43: +// CHECK-NEXT: br i1 [[TMP19]], label %[[CONT44]], label %[[TRAP43:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP43]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont44: +// CHECK: [[CONT44]]: // CHECK-NEXT: ret ptr [[WIDE_PTR_PTR34]] // flex_t *addrof_g(void) { @@ -155,7 +155,6 @@ flex_t *addrof_g(void) { // CHECK-LABEL: @addrof_deref_g( // CHECK-NEXT: entry: // CHECK-NEXT: [[AGG_TEMP:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 -// CHECK-NEXT: [[AGG_TEMP1:%.*]] = alloca [[STRUCT_FLEX_T:%.*]], align 4 // CHECK-NEXT: [[AGG_TEMP2:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP7:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @g_flex, align 4 @@ -181,32 +180,31 @@ flex_t *addrof_g(void) { // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} // CHECK: cont: // CHECK-NEXT: [[TMP6:%.*]] = icmp ule ptr [[WIDE_PTR_PTR]], [[TMP4]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP6]], label [[CONT4:%.*]], label [[TRAP3:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap3: +// CHECK-NEXT: br i1 [[TMP6]], label %[[CONT4:.*]], label %[[TRAP3:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP3]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont4: +// CHECK: [[CONT4]]: // CHECK-NEXT: [[TMP7:%.*]] = icmp uge ptr [[WIDE_PTR_PTR]], [[WIDE_PTR_LB]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP7]], label [[CONT6:%.*]], label [[TRAP5:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap5: +// CHECK-NEXT: br i1 [[TMP7]], label %[[CONT6:.*]], label %[[TRAP5:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP5]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont6: -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[AGG_TEMP1]], ptr align 4 [[WIDE_PTR_PTR]], i64 4, i1 false) -// CHECK-NEXT: [[ELEMS:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[AGG_TEMP1]], i32 0, i32 1 +// CHECK: [[CONT6]]: +// CHECK-NEXT: [[ELEMS:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [0 x i32], ptr [[ELEMS]], i64 0, i64 0 -// CHECK-NEXT: [[ELEMS8:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[AGG_TEMP1]], i32 0, i32 1 +// CHECK-NEXT: [[ELEMS8:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY9:%.*]] = getelementptr inbounds [0 x i32], ptr [[ELEMS8]], i64 0, i64 0 -// CHECK-NEXT: [[COUNT:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[AGG_TEMP1]], i32 0, i32 0 +// CHECK-NEXT: [[COUNT:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR]], i32 0, i32 0 // CHECK-NEXT: [[TMP8:%.*]] = load i32, ptr [[COUNT]], align 4 // CHECK-NEXT: [[IDX_EXT10:%.*]] = sext i32 [[TMP8]] to i64 // CHECK-NEXT: [[ADD_PTR11:%.*]] = getelementptr inbounds i32, ptr [[ARRAYDECAY9]], i64 [[IDX_EXT10]] // CHECK-NEXT: [[TMP9:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP7]], i32 0, i32 0 -// CHECK-NEXT: store ptr [[AGG_TEMP1]], ptr [[TMP9]], align 8 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR]], ptr [[TMP9]], align 8 // CHECK-NEXT: [[TMP10:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP7]], i32 0, i32 1 // CHECK-NEXT: store ptr [[ADD_PTR11]], ptr [[TMP10]], align 8 // CHECK-NEXT: [[TMP11:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP7]], i32 0, i32 2 -// CHECK-NEXT: store ptr [[AGG_TEMP1]], ptr [[TMP11]], align 8 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR]], ptr [[TMP11]], align 8 // CHECK-NEXT: [[WIDE_PTR_UB_ADDR12:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP7]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB13:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR12]], align 8 // CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP7]], i32 0, i32 0 @@ -228,23 +226,23 @@ flex_t *addrof_g(void) { // CHECK-NEXT: [[WIDE_PTR_LB21:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR20]], align 8 // CHECK-NEXT: [[TMP16:%.*]] = getelementptr i32, ptr [[ARRAYIDX]], i64 1, {{!annotation ![0-9]+}} // CHECK-NEXT: [[TMP17:%.*]] = icmp ule ptr [[TMP16]], [[WIDE_PTR_UB19]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP17]], label [[CONT23:%.*]], label [[TRAP22:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap22: +// CHECK-NEXT: br i1 [[TMP17]], label %[[CONT23:.*]], label %[[TRAP22:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP22]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont23: +// CHECK: [[CONT23]]: // CHECK-NEXT: [[TMP18:%.*]] = icmp ule ptr [[ARRAYIDX]], [[TMP16]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP18]], label [[CONT25:%.*]], label [[TRAP24:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap24: +// CHECK-NEXT: br i1 [[TMP18]], label %[[CONT25:.*]], label %[[TRAP24:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP24]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont25: +// CHECK: [[CONT25]]: // CHECK-NEXT: [[TMP19:%.*]] = icmp uge ptr [[ARRAYIDX]], [[WIDE_PTR_LB21]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP19]], label [[CONT27:%.*]], label [[TRAP26:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap26: +// CHECK-NEXT: br i1 [[TMP19]], label %[[CONT27:.*]], label %[[TRAP26:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP26]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont27: +// CHECK: [[CONT27]]: // CHECK-NEXT: [[TMP20:%.*]] = load i32, ptr [[ARRAYIDX]], align 4 // CHECK-NEXT: ret i32 [[TMP20]] // @@ -262,7 +260,6 @@ int addrof_deref_g(void) { // CHECK-NEXT: [[AGG_TEMP3:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP14:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP45:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8 -// CHECK-NEXT: [[AGG_TEMP46:%.*]] = alloca [[STRUCT_FLEX_T:%.*]], align 4 // CHECK-NEXT: [[AGG_TEMP47:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP66:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: store ptr [[P:%.*]], ptr [[P_INDIRECT_ADDR]], align 8 @@ -389,8 +386,8 @@ int addrof_deref_g(void) { // CHECK-NEXT: store ptr [[WIDE_PTR_PTR34]], ptr [[FLEX]], align 8 // CHECK-NEXT: [[TMP16:%.*]] = load ptr, ptr [[FLEX]], align 8 // CHECK-NEXT: [[TMP17:%.*]] = icmp ne ptr [[TMP16]], null, {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP17]], label [[BOUNDSCHECK_NOTNULL48:%.*]], label [[BOUNDSCHECK_NULL:%.*]], {{!annotation ![0-9]+}} -// CHECK: boundscheck.notnull48: +// CHECK-NEXT: br i1 [[TMP17]], label %[[BOUNDSCHECK_NOTNULL48:.*]], label [[BOUNDSCHECK_NULL:%.*]], {{!annotation ![0-9]+}} +// CHECK: [[BOUNDSCHECK_NOTNULL48]]: // CHECK-NEXT: [[ELEMS49:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[TMP16]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY50:%.*]] = getelementptr inbounds [0 x i32], ptr [[ELEMS49]], i64 0, i64 0 // CHECK-NEXT: [[COUNT51:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[TMP16]], i32 0, i32 0 @@ -421,38 +418,37 @@ int addrof_deref_g(void) { // CHECK-NEXT: [[WIDE_PTR_LB57:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR56]], align 8 // CHECK-NEXT: [[TMP25:%.*]] = getelementptr [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR53]], i64 1, {{!annotation ![0-9]+}} // CHECK-NEXT: [[TMP26:%.*]] = icmp ule ptr [[TMP25]], [[WIDE_PTR_UB55]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP26]], label [[CONT59:%.*]], label [[TRAP58:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap58: +// CHECK-NEXT: br i1 [[TMP26]], label %[[CONT59:.*]], label %[[TRAP58:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP58]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont59: +// CHECK: [[CONT59]]: // CHECK-NEXT: [[TMP27:%.*]] = icmp ule ptr [[WIDE_PTR_PTR53]], [[TMP25]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP27]], label [[CONT61:%.*]], label [[TRAP60:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap60: +// CHECK-NEXT: br i1 [[TMP27]], label %[[CONT61:.*]], label %[[TRAP60:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP60]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont61: +// CHECK: [[CONT61]]: // CHECK-NEXT: [[TMP28:%.*]] = icmp uge ptr [[WIDE_PTR_PTR53]], [[WIDE_PTR_LB57]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP28]], label [[CONT63:%.*]], label [[TRAP62:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap62: +// CHECK-NEXT: br i1 [[TMP28]], label %[[CONT63:.*]], label %[[TRAP62:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP62]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont63: -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[AGG_TEMP46]], ptr align 4 [[WIDE_PTR_PTR53]], i64 4, i1 false) -// CHECK-NEXT: [[ELEMS64:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[AGG_TEMP46]], i32 0, i32 1 +// CHECK: [[CONT63]]: +// CHECK-NEXT: [[ELEMS64:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR53]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY65:%.*]] = getelementptr inbounds [0 x i32], ptr [[ELEMS64]], i64 0, i64 0 -// CHECK-NEXT: [[ELEMS67:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[AGG_TEMP46]], i32 0, i32 1 +// CHECK-NEXT: [[ELEMS67:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR53]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY68:%.*]] = getelementptr inbounds [0 x i32], ptr [[ELEMS67]], i64 0, i64 0 -// CHECK-NEXT: [[COUNT69:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[AGG_TEMP46]], i32 0, i32 0 +// CHECK-NEXT: [[COUNT69:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[WIDE_PTR_PTR53]], i32 0, i32 0 // CHECK-NEXT: [[TMP29:%.*]] = load i32, ptr [[COUNT69]], align 4 // CHECK-NEXT: [[IDX_EXT70:%.*]] = sext i32 [[TMP29]] to i64 // CHECK-NEXT: [[ADD_PTR71:%.*]] = getelementptr inbounds i32, ptr [[ARRAYDECAY68]], i64 [[IDX_EXT70]] // CHECK-NEXT: [[TMP30:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP66]], i32 0, i32 0 -// CHECK-NEXT: store ptr [[AGG_TEMP46]], ptr [[TMP30]], align 8 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR53]], ptr [[TMP30]], align 8 // CHECK-NEXT: [[TMP31:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP66]], i32 0, i32 1 // CHECK-NEXT: store ptr [[ADD_PTR71]], ptr [[TMP31]], align 8 // CHECK-NEXT: [[TMP32:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP66]], i32 0, i32 2 -// CHECK-NEXT: store ptr [[AGG_TEMP46]], ptr [[TMP32]], align 8 +// CHECK-NEXT: store ptr [[WIDE_PTR_PTR53]], ptr [[TMP32]], align 8 // CHECK-NEXT: [[WIDE_PTR_UB_ADDR72:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP66]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB73:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR72]], align 8 // CHECK-NEXT: [[TMP33:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP66]], i32 0, i32 0 @@ -474,23 +470,23 @@ int addrof_deref_g(void) { // CHECK-NEXT: [[WIDE_PTR_LB81:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR80]], align 8 // CHECK-NEXT: [[TMP37:%.*]] = getelementptr i32, ptr [[ARRAYIDX]], i64 1, {{!annotation ![0-9]+}} // CHECK-NEXT: [[TMP38:%.*]] = icmp ule ptr [[TMP37]], [[WIDE_PTR_UB79]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP38]], label [[CONT83:%.*]], label [[TRAP82:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap82: +// CHECK-NEXT: br i1 [[TMP38]], label %[[CONT83:.*]], label %[[TRAP82:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP82]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont83: +// CHECK: [[CONT83]]: // CHECK-NEXT: [[TMP39:%.*]] = icmp ule ptr [[ARRAYIDX]], [[TMP37]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP39]], label [[CONT85:%.*]], label [[TRAP84:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap84: +// CHECK-NEXT: br i1 [[TMP39]], label %[[CONT85:.*]], label %[[TRAP84:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP84]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont85: +// CHECK: [[CONT85]]: // CHECK-NEXT: [[TMP40:%.*]] = icmp uge ptr [[ARRAYIDX]], [[WIDE_PTR_LB81]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP40]], label [[CONT87:%.*]], label [[TRAP86:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap86: +// CHECK-NEXT: br i1 [[TMP40]], label %[[CONT87:.*]], label %[[TRAP86:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP86]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont87: +// CHECK: [[CONT87]]: // CHECK-NEXT: store i32 10, ptr [[ARRAYIDX]], align 4 // CHECK-NEXT: ret void // diff --git a/clang/test/BoundsSafety/CodeGen/flexible-array-member-promotion-returns-O2.c b/clang/test/BoundsSafety/CodeGen/flexible-array-member-promotion-returns-O2.c index c7a7bf08e8463..cc5ba92e6c266 100644 --- a/clang/test/BoundsSafety/CodeGen/flexible-array-member-promotion-returns-O2.c +++ b/clang/test/BoundsSafety/CodeGen/flexible-array-member-promotion-returns-O2.c @@ -14,7 +14,7 @@ inline flex_t *return_flex(int *__counted_by(11) buf) { } // CHECK-LABEL: @pointer_assign_good( -// CHECK-NEXT: cont47: +// CHECK-NEXT: {{.*}}: // CHECK-NEXT: ret void // void pointer_assign_good() { @@ -24,7 +24,7 @@ void pointer_assign_good() { } // CHECK-LABEL: @pointer_assign_good2( -// CHECK-NEXT: cont47: +// CHECK-NEXT: {{.*}}: // CHECK-NEXT: ret void // void pointer_assign_good2() { @@ -34,7 +34,7 @@ void pointer_assign_good2() { } // CHECK-LABEL: @pointer_init_good( -// CHECK-NEXT: cont47: +// CHECK-NEXT: {{.*}}: // CHECK-NEXT: ret void // void pointer_init_good() { @@ -43,7 +43,7 @@ void pointer_init_good() { } // CHECK-LABEL: @pointer_init_good2( -// CHECK-NEXT: cont47: +// CHECK-NEXT: {{.*}}: // CHECK-NEXT: ret void // void pointer_init_good2() { @@ -96,7 +96,7 @@ void pointer_count_init_good() { } // CHECK-LABEL: @elem_access_good( -// CHECK-NEXT: cont69: +// CHECK-NEXT: {{.*}}: // CHECK-NEXT: ret void // void elem_access_good() { @@ -107,7 +107,7 @@ void elem_access_good() { } // CHECK-LABEL: @elem_access_trap( -// CHECK-NEXT: cont47: +// CHECK-NEXT: {{.*}}: // CHECK-NEXT: [[ARR:%.*]] = alloca [11 x i32], align 4 // CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 44, ptr nonnull [[ARR]]) #[[ATTR7:[0-9]+]] // CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds i8, ptr [[ARR]], i64 4 @@ -123,7 +123,7 @@ void elem_access_good() { // CHECK: trap: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR6]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont69: +// CHECK: {{.*}}: // CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 44, ptr nonnull [[ARR]]) #[[ATTR7]] // CHECK-NEXT: ret void // diff --git a/clang/test/BoundsSafety/CodeGen/multiple-dependees.c b/clang/test/BoundsSafety/CodeGen/multiple-dependees.c index 5bea3b9547a3f..ae3b63ab61c88 100644 --- a/clang/test/BoundsSafety/CodeGen/multiple-dependees.c +++ b/clang/test/BoundsSafety/CodeGen/multiple-dependees.c @@ -26,7 +26,6 @@ struct T { // CHECK-NEXT: [[AGG_TEMP20:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP32:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 // CHECK-NEXT: [[AGG_TEMP40:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8 -// CHECK-NEXT: [[AGG_TEMP41:%.*]] = alloca [[STRUCT_T]], align 8 // CHECK-NEXT: store i32 [[IDX:%.*]], ptr [[IDX_ADDR]], align 4 // CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 16 [[ARR]], i8 0, i64 64, i1 false) // CHECK-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [16 x i32], ptr [[ARR]], i64 0, i64 0 @@ -111,12 +110,11 @@ struct T { // CHECK-NEXT: [[WIDE_PTR_LB38:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR37]], align 8 // CHECK-NEXT: [[PTR39:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[T]], i32 0, i32 2 // CHECK-NEXT: store ptr [[WIDE_PTR_PTR34]], ptr [[PTR39]], align 8 -// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP41]], ptr align 8 [[T]], i64 16, i1 false) -// CHECK-NEXT: [[CNT142:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[AGG_TEMP41]], i32 0, i32 0 +// CHECK-NEXT: [[CNT142:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[T]], i32 0, i32 0 // CHECK-NEXT: [[TMP5:%.*]] = load i32, ptr [[CNT142]], align 8 -// CHECK-NEXT: [[CNT243:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[AGG_TEMP41]], i32 0, i32 1 +// CHECK-NEXT: [[CNT243:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[T]], i32 0, i32 1 // CHECK-NEXT: [[TMP6:%.*]] = load i32, ptr [[CNT243]], align 4 -// CHECK-NEXT: [[PTR44:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[AGG_TEMP41]], i32 0, i32 2 +// CHECK-NEXT: [[PTR44:%.*]] = getelementptr inbounds [[STRUCT_T]], ptr [[T]], i32 0, i32 2 // CHECK-NEXT: [[TMP7:%.*]] = load ptr, ptr [[PTR44]], align 8 // CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 2, [[TMP5]] // CHECK-NEXT: [[MUL45:%.*]] = mul nsw i32 3, [[TMP6]] @@ -140,23 +138,23 @@ struct T { // CHECK-NEXT: [[WIDE_PTR_LB51:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR50]], align 8 // CHECK-NEXT: [[TMP12:%.*]] = getelementptr i32, ptr [[ARRAYIDX]], i64 1, {{!annotation ![0-9]+}} // CHECK-NEXT: [[TMP13:%.*]] = icmp ule ptr [[TMP12]], [[WIDE_PTR_UB49]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP13]], label [[CONT53:%.*]], label [[TRAP52:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap52: +// CHECK-NEXT: br i1 [[TMP13]], label %[[CONT53:.*]], label %[[TRAP52:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP52]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont53: +// CHECK: [[CONT53]]: // CHECK-NEXT: [[TMP14:%.*]] = icmp ule ptr [[ARRAYIDX]], [[TMP12]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP14]], label [[CONT55:%.*]], label [[TRAP54:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap54: +// CHECK-NEXT: br i1 [[TMP14]], label %[[CONT55:.*]], label %[[TRAP54:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP54]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont55: +// CHECK: [[CONT55]]: // CHECK-NEXT: [[TMP15:%.*]] = icmp uge ptr [[ARRAYIDX]], [[WIDE_PTR_LB51]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[TMP15]], label [[CONT57:%.*]], label [[TRAP56:%.*]], {{!annotation ![0-9]+}} -// CHECK: trap56: +// CHECK-NEXT: br i1 [[TMP15]], label %[[CONT57:.*]], label %[[TRAP56:.*]], {{!annotation ![0-9]+}} +// CHECK: [[TRAP56]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont57: +// CHECK: [[CONT57]]: // CHECK-NEXT: [[TMP16:%.*]] = load i32, ptr [[ARRAYIDX]], align 4 // CHECK-NEXT: ret i32 [[TMP16]] // diff --git a/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-O2.c b/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-O2.c index 3e8b455c78297..8611ba13f2194 100644 --- a/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-O2.c +++ b/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-O2.c @@ -18,10 +18,10 @@ void use(void *__unsafe_indexable); // CHECK-SAME: ptr noundef [[FRAME:%.*]], i32 noundef [[FRAME_SIZE:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: [[IDX_EXT:%.*]] = zext i32 [[FRAME_SIZE]] to i64 -// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds nuw i8, ptr [[FRAME]], i64 [[IDX_EXT]] +// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[FRAME]], i64 [[IDX_EXT]] // CHECK-NEXT: [[TMP0:%.*]] = getelementptr i8, ptr [[FRAME]], i64 4 // CHECK-NEXT: [[DOTNOT:%.*]] = icmp ugt ptr [[TMP0]], [[ADD_PTR]], !annotation [[META2:![0-9]+]] -// CHECK-NEXT: br i1 [[DOTNOT]], label %[[TRAP:.*]], label %[[CONT10:.*]], !prof [[PROF3:![0-9]+]], !annotation [[META2]] +// CHECK-NEXT: br i1 [[DOTNOT]], label %[[TRAP:.*]], label %[[CONT10:.*]], !annotation [[META2]] // CHECK: [[TRAP]]: // CHECK-NEXT: tail call void @llvm.ubsantrap(i8 25) #[[ATTR3:[0-9]+]], !annotation [[META4:![0-9]+]] // CHECK-NEXT: unreachable, !annotation [[META4]] @@ -39,6 +39,5 @@ void process_frame(char *__counted_by(frame_size) frame, unsigned frame_size) { } //. // CHECK: [[META2]] = !{!"bounds-safety-check-ptr-lt-upper-bound"} -// CHECK: [[PROF3]] = !{!"branch_weights", i32 8191, i32 -8192} // CHECK: [[META4]] = !{!"bounds-safety-check-ptr-lt-upper-bound", !"bounds-safety-check-ptr-ge-lower-bound"} //. diff --git a/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-nested-len-O2.c b/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-nested-len-O2.c index 5391831035d85..c3971820fd805 100644 --- a/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-nested-len-O2.c +++ b/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-nested-len-O2.c @@ -23,10 +23,10 @@ void use(void *__unsafe_indexable); // CHECK-SAME: ptr noundef [[FRAME:%.*]], i32 noundef [[FRAME_SIZE:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: [[IDX_EXT:%.*]] = zext i32 [[FRAME_SIZE]] to i64 -// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds nuw i8, ptr [[FRAME]], i64 [[IDX_EXT]] +// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[FRAME]], i64 [[IDX_EXT]] // CHECK-NEXT: [[TMP0:%.*]] = getelementptr i8, ptr [[FRAME]], i64 4 // CHECK-NEXT: [[DOTNOT:%.*]] = icmp ugt ptr [[TMP0]], [[ADD_PTR]], !annotation [[META2:![0-9]+]] -// CHECK-NEXT: br i1 [[DOTNOT]], label %[[TRAP:.*]], label %[[CONT10:.*]], !prof [[PROF3:![0-9]+]], !annotation [[META2]] +// CHECK-NEXT: br i1 [[DOTNOT]], label %[[TRAP:.*]], label %[[CONT10:.*]], !annotation [[META2]] // CHECK: [[TRAP]]: // CHECK-NEXT: tail call void @llvm.ubsantrap(i8 25) #[[ATTR3:[0-9]+]], !annotation [[META4:![0-9]+]] // CHECK-NEXT: unreachable, !annotation [[META4]] @@ -44,6 +44,5 @@ void process_frame(char *__counted_by(frame_size) frame, unsigned frame_size) { } //. // CHECK: [[META2]] = !{!"bounds-safety-check-ptr-lt-upper-bound"} -// CHECK: [[PROF3]] = !{!"branch_weights", i32 8191, i32 -8192} // CHECK: [[META4]] = !{!"bounds-safety-check-ptr-lt-upper-bound", !"bounds-safety-check-ptr-ge-lower-bound"} //. diff --git a/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-nested-len.c b/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-nested-len.c index d141dfae4fed0..745f5cf8e636c 100644 --- a/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-nested-len.c +++ b/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member-nested-len.c @@ -43,223 +43,223 @@ void use(void *__unsafe_indexable); // CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[FRAME_ADDR]], align 8 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[FRAME_SIZE_ADDR]], align 4 // CHECK-NEXT: [[IDX_EXT:%.*]] = zext i32 [[TMP1]] to i64 -// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP0]], i64 [[IDX_EXT]] -// CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 0 +// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[TMP0]], i64 [[IDX_EXT]] +// CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 0 // CHECK-NEXT: store ptr [[TMP0]], ptr [[TMP2]], align 8 -// CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 1 +// CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 1 // CHECK-NEXT: store ptr [[ADD_PTR]], ptr [[TMP3]], align 8 -// CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 2 +// CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 2 // CHECK-NEXT: store ptr [[TMP0]], ptr [[TMP4]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR]], align 8 -// CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 0 +// CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 0 // CHECK-NEXT: store ptr [[WIDE_PTR_PTR]], ptr [[TMP5]], align 8 -// CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 1 +// CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 1 // CHECK-NEXT: store ptr [[WIDE_PTR_UB]], ptr [[TMP6]], align 8 -// CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 2 +// CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 2 // CHECK-NEXT: store ptr [[WIDE_PTR_LB]], ptr [[TMP7]], align 8 // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP3]], ptr align 8 [[OF]], i64 24, i1 false) -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR4:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR4:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR5:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR4]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR6:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR6:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB7:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR6]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR8:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR8:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB9:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR8]], align 8 // CHECK-NEXT: [[TMP8:%.*]] = getelementptr [[STRUCT_OUTER_FLEX_T:%.*]], ptr [[WIDE_PTR_PTR5]], i64 1 // CHECK-NEXT: [[TMP9:%.*]] = icmp ule ptr [[TMP8]], [[WIDE_PTR_UB7]], !annotation [[META2:![0-9]+]] -// CHECK-NEXT: br i1 [[TMP9]], label %[[CONT:.*]], label %[[TRAP:.*]], !prof [[PROF3:![0-9]+]], !annotation [[META2]] +// CHECK-NEXT: br i1 [[TMP9]], label %[[CONT:.*]], label %[[TRAP:.*]], !annotation [[META2]] // CHECK: [[TRAP]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4:[0-9]+]], !annotation [[META2]] // CHECK-NEXT: unreachable, !annotation [[META2]] // CHECK: [[CONT]]: // CHECK-NEXT: [[TMP10:%.*]] = icmp ule ptr [[WIDE_PTR_LB9]], [[WIDE_PTR_PTR5]], !annotation [[META4:![0-9]+]] -// CHECK-NEXT: br i1 [[TMP10]], label %[[CONT11:.*]], label %[[TRAP10:.*]], !prof [[PROF3]], !annotation [[META4]] +// CHECK-NEXT: br i1 [[TMP10]], label %[[CONT11:.*]], label %[[TRAP10:.*]], !annotation [[META4]] // CHECK: [[TRAP10]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META4]] // CHECK-NEXT: unreachable, !annotation [[META4]] // CHECK: [[CONT11]]: -// CHECK-NEXT: [[F:%.*]] = getelementptr inbounds nuw [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR5]], i32 0, i32 0 -// CHECK-NEXT: [[ARR:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T:%.*]], ptr [[F]], i32 0, i32 1 +// CHECK-NEXT: [[F:%.*]] = getelementptr inbounds [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR5]], i32 0, i32 0 +// CHECK-NEXT: [[ARR:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T:%.*]], ptr [[F]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR]], i64 0, i64 0 -// CHECK-NEXT: [[HEADER:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F]], i32 0, i32 0 -// CHECK-NEXT: [[COUNT:%.*]] = getelementptr inbounds nuw [[STRUCT_HEADER_T:%.*]], ptr [[HEADER]], i32 0, i32 0 +// CHECK-NEXT: [[HEADER:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[F]], i32 0, i32 0 +// CHECK-NEXT: [[COUNT:%.*]] = getelementptr inbounds [[STRUCT_HEADER_T:%.*]], ptr [[HEADER]], i32 0, i32 0 // CHECK-NEXT: [[TMP11:%.*]] = load i32, ptr [[COUNT]], align 4 // CHECK-NEXT: [[IDX_EXT12:%.*]] = sext i32 [[TMP11]] to i64 // CHECK-NEXT: [[ADD_PTR13:%.*]] = getelementptr inbounds i8, ptr [[ARRAYDECAY]], i64 [[IDX_EXT12]] -// CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 0 +// CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 0 // CHECK-NEXT: store ptr [[F]], ptr [[TMP12]], align 8 -// CHECK-NEXT: [[TMP13:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 1 +// CHECK-NEXT: [[TMP13:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 1 // CHECK-NEXT: store ptr [[ADD_PTR13]], ptr [[TMP13]], align 8 -// CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 2 +// CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 2 // CHECK-NEXT: store ptr [[F]], ptr [[TMP14]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR14:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR14:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR15:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR14]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR16:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR16:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB17:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR16]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR18:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR18:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB19:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR18]], align 8 -// CHECK-NEXT: [[TMP15:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 0 +// CHECK-NEXT: [[TMP15:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 0 // CHECK-NEXT: store ptr [[WIDE_PTR_PTR15]], ptr [[TMP15]], align 8 -// CHECK-NEXT: [[TMP16:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 1 +// CHECK-NEXT: [[TMP16:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 1 // CHECK-NEXT: store ptr [[WIDE_PTR_UB17]], ptr [[TMP16]], align 8 -// CHECK-NEXT: [[TMP17:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 2 +// CHECK-NEXT: [[TMP17:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 2 // CHECK-NEXT: store ptr [[WIDE_PTR_LB19]], ptr [[TMP17]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR20:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR20:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR21:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR20]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR22:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR22:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB23:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR22]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR24:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR24:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB25:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR24]], align 8 // CHECK-NEXT: call void @use(ptr noundef [[WIDE_PTR_PTR21]]) // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP28]], ptr align 8 [[OF]], i64 24, i1 false) -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR29:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR29:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR30:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR29]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR31:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR31:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB32:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR31]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR33:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR33:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB34:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR33]], align 8 // CHECK-NEXT: [[TMP18:%.*]] = getelementptr [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR30]], i64 1 // CHECK-NEXT: [[TMP19:%.*]] = icmp ule ptr [[TMP18]], [[WIDE_PTR_UB32]], !annotation [[META2]] -// CHECK-NEXT: br i1 [[TMP19]], label %[[CONT36:.*]], label %[[TRAP35:.*]], !prof [[PROF3]], !annotation [[META2]] +// CHECK-NEXT: br i1 [[TMP19]], label %[[CONT36:.*]], label %[[TRAP35:.*]], !annotation [[META2]] // CHECK: [[TRAP35]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META2]] // CHECK-NEXT: unreachable, !annotation [[META2]] // CHECK: [[CONT36]]: // CHECK-NEXT: [[TMP20:%.*]] = icmp ule ptr [[WIDE_PTR_LB34]], [[WIDE_PTR_PTR30]], !annotation [[META4]] -// CHECK-NEXT: br i1 [[TMP20]], label %[[CONT38:.*]], label %[[TRAP37:.*]], !prof [[PROF3]], !annotation [[META4]] +// CHECK-NEXT: br i1 [[TMP20]], label %[[CONT38:.*]], label %[[TRAP37:.*]], !annotation [[META4]] // CHECK: [[TRAP37]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META4]] // CHECK-NEXT: unreachable, !annotation [[META4]] // CHECK: [[CONT38]]: -// CHECK-NEXT: [[F39:%.*]] = getelementptr inbounds nuw [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR30]], i32 0, i32 0 -// CHECK-NEXT: [[ARR40:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 1 +// CHECK-NEXT: [[F39:%.*]] = getelementptr inbounds [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR30]], i32 0, i32 0 +// CHECK-NEXT: [[ARR40:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY41:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR40]], i64 0, i64 0 -// CHECK-NEXT: [[ARR43:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 1 +// CHECK-NEXT: [[ARR43:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY44:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR43]], i64 0, i64 0 -// CHECK-NEXT: [[HEADER45:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 0 -// CHECK-NEXT: [[COUNT46:%.*]] = getelementptr inbounds nuw [[STRUCT_HEADER_T]], ptr [[HEADER45]], i32 0, i32 0 +// CHECK-NEXT: [[HEADER45:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 0 +// CHECK-NEXT: [[COUNT46:%.*]] = getelementptr inbounds [[STRUCT_HEADER_T]], ptr [[HEADER45]], i32 0, i32 0 // CHECK-NEXT: [[TMP21:%.*]] = load i32, ptr [[COUNT46]], align 4 // CHECK-NEXT: [[IDX_EXT47:%.*]] = sext i32 [[TMP21]] to i64 // CHECK-NEXT: [[ADD_PTR48:%.*]] = getelementptr inbounds i8, ptr [[ARRAYDECAY44]], i64 [[IDX_EXT47]] -// CHECK-NEXT: [[TMP22:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 +// CHECK-NEXT: [[TMP22:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 // CHECK-NEXT: store ptr [[F39]], ptr [[TMP22]], align 8 -// CHECK-NEXT: [[TMP23:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 1 +// CHECK-NEXT: [[TMP23:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 1 // CHECK-NEXT: store ptr [[ADD_PTR48]], ptr [[TMP23]], align 8 -// CHECK-NEXT: [[TMP24:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 2 +// CHECK-NEXT: [[TMP24:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 2 // CHECK-NEXT: store ptr [[F39]], ptr [[TMP24]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR49:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR49:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB50:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR49]], align 8 -// CHECK-NEXT: [[TMP25:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 +// CHECK-NEXT: [[TMP25:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 // CHECK-NEXT: store ptr [[WIDE_PTR_UB50]], ptr [[TMP25]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR51:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR51:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR52:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR51]], align 8 -// CHECK-NEXT: [[TMP26:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 0 +// CHECK-NEXT: [[TMP26:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 0 // CHECK-NEXT: store ptr [[ARRAYDECAY41]], ptr [[TMP26]], align 8 -// CHECK-NEXT: [[TMP27:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 1 +// CHECK-NEXT: [[TMP27:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 1 // CHECK-NEXT: store ptr [[WIDE_PTR_PTR52]], ptr [[TMP27]], align 8 -// CHECK-NEXT: [[TMP28:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 2 +// CHECK-NEXT: [[TMP28:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 2 // CHECK-NEXT: store ptr [[ARRAYDECAY41]], ptr [[TMP28]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR53:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR53:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR54:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR53]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR55:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR55:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB56:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR55]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR57:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR57:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB58:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR57]], align 8 -// CHECK-NEXT: [[TMP29:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 0 +// CHECK-NEXT: [[TMP29:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 0 // CHECK-NEXT: store ptr [[WIDE_PTR_PTR54]], ptr [[TMP29]], align 8 -// CHECK-NEXT: [[TMP30:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 1 +// CHECK-NEXT: [[TMP30:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 1 // CHECK-NEXT: store ptr [[WIDE_PTR_UB56]], ptr [[TMP30]], align 8 -// CHECK-NEXT: [[TMP31:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 2 +// CHECK-NEXT: [[TMP31:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 2 // CHECK-NEXT: store ptr [[WIDE_PTR_LB58]], ptr [[TMP31]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR59:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR59:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR60:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR59]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR61:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR61:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB62:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR61]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR63:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR63:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB64:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR63]], align 8 // CHECK-NEXT: call void @use(ptr noundef [[WIDE_PTR_PTR60]]) // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP67]], ptr align 8 [[OF]], i64 24, i1 false) -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR68:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP67]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR68:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP67]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR69:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR68]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR70:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP67]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR70:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP67]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB71:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR70]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR72:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP67]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR72:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP67]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB73:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR72]], align 8 // CHECK-NEXT: [[TMP32:%.*]] = getelementptr [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR69]], i64 1 // CHECK-NEXT: [[TMP33:%.*]] = icmp ule ptr [[TMP32]], [[WIDE_PTR_UB71]], !annotation [[META2]] -// CHECK-NEXT: br i1 [[TMP33]], label %[[CONT75:.*]], label %[[TRAP74:.*]], !prof [[PROF3]], !annotation [[META2]] +// CHECK-NEXT: br i1 [[TMP33]], label %[[CONT75:.*]], label %[[TRAP74:.*]], !annotation [[META2]] // CHECK: [[TRAP74]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META2]] // CHECK-NEXT: unreachable, !annotation [[META2]] // CHECK: [[CONT75]]: // CHECK-NEXT: [[TMP34:%.*]] = icmp ule ptr [[WIDE_PTR_LB73]], [[WIDE_PTR_PTR69]], !annotation [[META4]] -// CHECK-NEXT: br i1 [[TMP34]], label %[[CONT77:.*]], label %[[TRAP76:.*]], !prof [[PROF3]], !annotation [[META4]] +// CHECK-NEXT: br i1 [[TMP34]], label %[[CONT77:.*]], label %[[TRAP76:.*]], !annotation [[META4]] // CHECK: [[TRAP76]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META4]] // CHECK-NEXT: unreachable, !annotation [[META4]] // CHECK: [[CONT77]]: -// CHECK-NEXT: [[F78:%.*]] = getelementptr inbounds nuw [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR69]], i32 0, i32 0 -// CHECK-NEXT: [[ARR79:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F78]], i32 0, i32 1 +// CHECK-NEXT: [[F78:%.*]] = getelementptr inbounds [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR69]], i32 0, i32 0 +// CHECK-NEXT: [[ARR79:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[F78]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY80:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR79]], i64 0, i64 0 -// CHECK-NEXT: [[ARR82:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F78]], i32 0, i32 1 +// CHECK-NEXT: [[ARR82:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[F78]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY83:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR82]], i64 0, i64 0 -// CHECK-NEXT: [[HEADER84:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F78]], i32 0, i32 0 -// CHECK-NEXT: [[COUNT85:%.*]] = getelementptr inbounds nuw [[STRUCT_HEADER_T]], ptr [[HEADER84]], i32 0, i32 0 +// CHECK-NEXT: [[HEADER84:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[F78]], i32 0, i32 0 +// CHECK-NEXT: [[COUNT85:%.*]] = getelementptr inbounds [[STRUCT_HEADER_T]], ptr [[HEADER84]], i32 0, i32 0 // CHECK-NEXT: [[TMP35:%.*]] = load i32, ptr [[COUNT85]], align 4 // CHECK-NEXT: [[IDX_EXT86:%.*]] = sext i32 [[TMP35]] to i64 // CHECK-NEXT: [[ADD_PTR87:%.*]] = getelementptr inbounds i8, ptr [[ARRAYDECAY83]], i64 [[IDX_EXT86]] -// CHECK-NEXT: [[TMP36:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 0 +// CHECK-NEXT: [[TMP36:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 0 // CHECK-NEXT: store ptr [[F78]], ptr [[TMP36]], align 8 -// CHECK-NEXT: [[TMP37:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 1 +// CHECK-NEXT: [[TMP37:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 1 // CHECK-NEXT: store ptr [[ADD_PTR87]], ptr [[TMP37]], align 8 -// CHECK-NEXT: [[TMP38:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 2 +// CHECK-NEXT: [[TMP38:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 2 // CHECK-NEXT: store ptr [[F78]], ptr [[TMP38]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR88:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR88:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB89:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR88]], align 8 -// CHECK-NEXT: [[TMP39:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 0 +// CHECK-NEXT: [[TMP39:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 0 // CHECK-NEXT: store ptr [[WIDE_PTR_UB89]], ptr [[TMP39]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR90:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR90:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP81]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR91:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR90]], align 8 -// CHECK-NEXT: [[TMP40:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 0 +// CHECK-NEXT: [[TMP40:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 0 // CHECK-NEXT: store ptr [[ARRAYDECAY80]], ptr [[TMP40]], align 8 -// CHECK-NEXT: [[TMP41:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 1 +// CHECK-NEXT: [[TMP41:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 1 // CHECK-NEXT: store ptr [[WIDE_PTR_PTR91]], ptr [[TMP41]], align 8 -// CHECK-NEXT: [[TMP42:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 2 +// CHECK-NEXT: [[TMP42:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 2 // CHECK-NEXT: store ptr [[ARRAYDECAY80]], ptr [[TMP42]], align 8 -// CHECK-NEXT: [[TMP43:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 0 +// CHECK-NEXT: [[TMP43:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 0 // CHECK-NEXT: [[TMP44:%.*]] = load ptr, ptr [[TMP43]], align 8 // CHECK-NEXT: [[BOUND_PTR_ARITH:%.*]] = getelementptr i8, ptr [[TMP44]], i64 0 -// CHECK-NEXT: [[TMP45:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 0 +// CHECK-NEXT: [[TMP45:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 0 // CHECK-NEXT: store ptr [[BOUND_PTR_ARITH]], ptr [[TMP45]], align 8 -// CHECK-NEXT: [[TMP46:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 1 +// CHECK-NEXT: [[TMP46:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 1 // CHECK-NEXT: [[TMP47:%.*]] = load ptr, ptr [[TMP46]], align 8 -// CHECK-NEXT: [[TMP48:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 1 +// CHECK-NEXT: [[TMP48:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 1 // CHECK-NEXT: store ptr [[TMP47]], ptr [[TMP48]], align 8 -// CHECK-NEXT: [[TMP49:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 2 +// CHECK-NEXT: [[TMP49:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 2 // CHECK-NEXT: [[TMP50:%.*]] = load ptr, ptr [[TMP49]], align 8 -// CHECK-NEXT: [[TMP51:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 2 +// CHECK-NEXT: [[TMP51:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 2 // CHECK-NEXT: store ptr [[TMP50]], ptr [[TMP51]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR92:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR92:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR93:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR92]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR94:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR94:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB95:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR94]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR96:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR96:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP66]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB97:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR96]], align 8 -// CHECK-NEXT: [[TMP52:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 0 +// CHECK-NEXT: [[TMP52:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 0 // CHECK-NEXT: store ptr [[WIDE_PTR_PTR93]], ptr [[TMP52]], align 8 -// CHECK-NEXT: [[TMP53:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 1 +// CHECK-NEXT: [[TMP53:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 1 // CHECK-NEXT: store ptr [[WIDE_PTR_UB95]], ptr [[TMP53]], align 8 -// CHECK-NEXT: [[TMP54:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 2 +// CHECK-NEXT: [[TMP54:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 2 // CHECK-NEXT: store ptr [[WIDE_PTR_LB97]], ptr [[TMP54]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR98:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR98:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR99:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR98]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR100:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR100:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB101:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR100]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR102:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR102:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP65]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB103:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR102]], align 8 // CHECK-NEXT: call void @use(ptr noundef [[WIDE_PTR_PTR99]]) // CHECK-NEXT: ret void @@ -272,6 +272,5 @@ void process_frame(char *__counted_by(frame_size) frame, unsigned frame_size) { } //. // CHECK: [[META2]] = !{!"bounds-safety-check-ptr-lt-upper-bound"} -// CHECK: [[PROF3]] = !{!"branch_weights", i32 1048575, i32 1} // CHECK: [[META4]] = !{!"bounds-safety-check-ptr-ge-lower-bound"} //. diff --git a/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member.c b/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member.c index e4c2f087c761b..1a39083686e61 100644 --- a/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member.c +++ b/clang/test/BoundsSafety/CodeGen/nested-flexible-array-member.c @@ -38,220 +38,220 @@ void use(void *__unsafe_indexable); // CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[FRAME_ADDR]], align 8 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[FRAME_SIZE_ADDR]], align 4 // CHECK-NEXT: [[IDX_EXT:%.*]] = zext i32 [[TMP1]] to i64 -// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP0]], i64 [[IDX_EXT]] -// CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 0 +// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[TMP0]], i64 [[IDX_EXT]] +// CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 0 // CHECK-NEXT: store ptr [[TMP0]], ptr [[TMP2]], align 8 -// CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 1 +// CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 1 // CHECK-NEXT: store ptr [[ADD_PTR]], ptr [[TMP3]], align 8 -// CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 2 +// CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 2 // CHECK-NEXT: store ptr [[TMP0]], ptr [[TMP4]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR]], align 8 -// CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 0 +// CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 0 // CHECK-NEXT: store ptr [[WIDE_PTR_PTR]], ptr [[TMP5]], align 8 -// CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 1 +// CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 1 // CHECK-NEXT: store ptr [[WIDE_PTR_UB]], ptr [[TMP6]], align 8 -// CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 2 +// CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[OF]], i32 0, i32 2 // CHECK-NEXT: store ptr [[WIDE_PTR_LB]], ptr [[TMP7]], align 8 // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP3]], ptr align 8 [[OF]], i64 24, i1 false) -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR4:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR4:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR5:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR4]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR6:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR6:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB7:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR6]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR8:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR8:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP3]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB9:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR8]], align 8 // CHECK-NEXT: [[TMP8:%.*]] = getelementptr [[STRUCT_OUTER_FLEX_T:%.*]], ptr [[WIDE_PTR_PTR5]], i64 1 // CHECK-NEXT: [[TMP9:%.*]] = icmp ule ptr [[TMP8]], [[WIDE_PTR_UB7]], !annotation [[META2:![0-9]+]] -// CHECK-NEXT: br i1 [[TMP9]], label %[[CONT:.*]], label %[[TRAP:.*]], !prof [[PROF3:![0-9]+]], !annotation [[META2]] +// CHECK-NEXT: br i1 [[TMP9]], label %[[CONT:.*]], label %[[TRAP:.*]], !annotation [[META2]] // CHECK: [[TRAP]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4:[0-9]+]], !annotation [[META2]] // CHECK-NEXT: unreachable, !annotation [[META2]] // CHECK: [[CONT]]: // CHECK-NEXT: [[TMP10:%.*]] = icmp ule ptr [[WIDE_PTR_LB9]], [[WIDE_PTR_PTR5]], !annotation [[META4:![0-9]+]] -// CHECK-NEXT: br i1 [[TMP10]], label %[[CONT11:.*]], label %[[TRAP10:.*]], !prof [[PROF3]], !annotation [[META4]] +// CHECK-NEXT: br i1 [[TMP10]], label %[[CONT11:.*]], label %[[TRAP10:.*]], !annotation [[META4]] // CHECK: [[TRAP10]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META4]] // CHECK-NEXT: unreachable, !annotation [[META4]] // CHECK: [[CONT11]]: -// CHECK-NEXT: [[F:%.*]] = getelementptr inbounds nuw [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR5]], i32 0, i32 0 -// CHECK-NEXT: [[ARR:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T:%.*]], ptr [[F]], i32 0, i32 1 +// CHECK-NEXT: [[F:%.*]] = getelementptr inbounds [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR5]], i32 0, i32 0 +// CHECK-NEXT: [[ARR:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T:%.*]], ptr [[F]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR]], i64 0, i64 0 -// CHECK-NEXT: [[COUNT:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F]], i32 0, i32 0 +// CHECK-NEXT: [[COUNT:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[F]], i32 0, i32 0 // CHECK-NEXT: [[TMP11:%.*]] = load i32, ptr [[COUNT]], align 4 // CHECK-NEXT: [[IDX_EXT12:%.*]] = sext i32 [[TMP11]] to i64 // CHECK-NEXT: [[ADD_PTR13:%.*]] = getelementptr inbounds i8, ptr [[ARRAYDECAY]], i64 [[IDX_EXT12]] -// CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 0 +// CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 0 // CHECK-NEXT: store ptr [[F]], ptr [[TMP12]], align 8 -// CHECK-NEXT: [[TMP13:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 1 +// CHECK-NEXT: [[TMP13:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 1 // CHECK-NEXT: store ptr [[ADD_PTR13]], ptr [[TMP13]], align 8 -// CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 2 +// CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 2 // CHECK-NEXT: store ptr [[F]], ptr [[TMP14]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR14:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR14:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR15:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR14]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR16:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR16:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB17:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR16]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR18:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR18:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP2]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB19:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR18]], align 8 -// CHECK-NEXT: [[TMP15:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 0 +// CHECK-NEXT: [[TMP15:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 0 // CHECK-NEXT: store ptr [[WIDE_PTR_PTR15]], ptr [[TMP15]], align 8 -// CHECK-NEXT: [[TMP16:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 1 +// CHECK-NEXT: [[TMP16:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 1 // CHECK-NEXT: store ptr [[WIDE_PTR_UB17]], ptr [[TMP16]], align 8 -// CHECK-NEXT: [[TMP17:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 2 +// CHECK-NEXT: [[TMP17:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 2 // CHECK-NEXT: store ptr [[WIDE_PTR_LB19]], ptr [[TMP17]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR20:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR20:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR21:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR20]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR22:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR22:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB23:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR22]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR24:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR24:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP1]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB25:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR24]], align 8 // CHECK-NEXT: call void @use(ptr noundef [[WIDE_PTR_PTR21]]) // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP28]], ptr align 8 [[OF]], i64 24, i1 false) -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR29:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR29:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR30:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR29]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR31:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR31:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB32:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR31]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR33:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR33:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP28]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB34:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR33]], align 8 // CHECK-NEXT: [[TMP18:%.*]] = getelementptr [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR30]], i64 1 // CHECK-NEXT: [[TMP19:%.*]] = icmp ule ptr [[TMP18]], [[WIDE_PTR_UB32]], !annotation [[META2]] -// CHECK-NEXT: br i1 [[TMP19]], label %[[CONT36:.*]], label %[[TRAP35:.*]], !prof [[PROF3]], !annotation [[META2]] +// CHECK-NEXT: br i1 [[TMP19]], label %[[CONT36:.*]], label %[[TRAP35:.*]], !annotation [[META2]] // CHECK: [[TRAP35]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META2]] // CHECK-NEXT: unreachable, !annotation [[META2]] // CHECK: [[CONT36]]: // CHECK-NEXT: [[TMP20:%.*]] = icmp ule ptr [[WIDE_PTR_LB34]], [[WIDE_PTR_PTR30]], !annotation [[META4]] -// CHECK-NEXT: br i1 [[TMP20]], label %[[CONT38:.*]], label %[[TRAP37:.*]], !prof [[PROF3]], !annotation [[META4]] +// CHECK-NEXT: br i1 [[TMP20]], label %[[CONT38:.*]], label %[[TRAP37:.*]], !annotation [[META4]] // CHECK: [[TRAP37]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META4]] // CHECK-NEXT: unreachable, !annotation [[META4]] // CHECK: [[CONT38]]: -// CHECK-NEXT: [[F39:%.*]] = getelementptr inbounds nuw [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR30]], i32 0, i32 0 -// CHECK-NEXT: [[ARR40:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 1 +// CHECK-NEXT: [[F39:%.*]] = getelementptr inbounds [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR30]], i32 0, i32 0 +// CHECK-NEXT: [[ARR40:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY41:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR40]], i64 0, i64 0 -// CHECK-NEXT: [[ARR43:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 1 +// CHECK-NEXT: [[ARR43:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY44:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR43]], i64 0, i64 0 -// CHECK-NEXT: [[COUNT45:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 0 +// CHECK-NEXT: [[COUNT45:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[F39]], i32 0, i32 0 // CHECK-NEXT: [[TMP21:%.*]] = load i32, ptr [[COUNT45]], align 4 // CHECK-NEXT: [[IDX_EXT46:%.*]] = sext i32 [[TMP21]] to i64 // CHECK-NEXT: [[ADD_PTR47:%.*]] = getelementptr inbounds i8, ptr [[ARRAYDECAY44]], i64 [[IDX_EXT46]] -// CHECK-NEXT: [[TMP22:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 +// CHECK-NEXT: [[TMP22:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 // CHECK-NEXT: store ptr [[F39]], ptr [[TMP22]], align 8 -// CHECK-NEXT: [[TMP23:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 1 +// CHECK-NEXT: [[TMP23:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 1 // CHECK-NEXT: store ptr [[ADD_PTR47]], ptr [[TMP23]], align 8 -// CHECK-NEXT: [[TMP24:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 2 +// CHECK-NEXT: [[TMP24:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 2 // CHECK-NEXT: store ptr [[F39]], ptr [[TMP24]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR48:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR48:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB49:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR48]], align 8 -// CHECK-NEXT: [[TMP25:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 +// CHECK-NEXT: [[TMP25:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 // CHECK-NEXT: store ptr [[WIDE_PTR_UB49]], ptr [[TMP25]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR50:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR50:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP42]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR51:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR50]], align 8 -// CHECK-NEXT: [[TMP26:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 0 +// CHECK-NEXT: [[TMP26:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 0 // CHECK-NEXT: store ptr [[ARRAYDECAY41]], ptr [[TMP26]], align 8 -// CHECK-NEXT: [[TMP27:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 1 +// CHECK-NEXT: [[TMP27:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 1 // CHECK-NEXT: store ptr [[WIDE_PTR_PTR51]], ptr [[TMP27]], align 8 -// CHECK-NEXT: [[TMP28:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 2 +// CHECK-NEXT: [[TMP28:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 2 // CHECK-NEXT: store ptr [[ARRAYDECAY41]], ptr [[TMP28]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR52:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR52:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR53:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR52]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR54:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR54:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB55:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR54]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR56:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR56:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP27]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB57:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR56]], align 8 -// CHECK-NEXT: [[TMP29:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 0 +// CHECK-NEXT: [[TMP29:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 0 // CHECK-NEXT: store ptr [[WIDE_PTR_PTR53]], ptr [[TMP29]], align 8 -// CHECK-NEXT: [[TMP30:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 1 +// CHECK-NEXT: [[TMP30:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 1 // CHECK-NEXT: store ptr [[WIDE_PTR_UB55]], ptr [[TMP30]], align 8 -// CHECK-NEXT: [[TMP31:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 2 +// CHECK-NEXT: [[TMP31:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 2 // CHECK-NEXT: store ptr [[WIDE_PTR_LB57]], ptr [[TMP31]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR58:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR58:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR59:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR58]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR60:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR60:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB61:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR60]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR62:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR62:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP26]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB63:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR62]], align 8 // CHECK-NEXT: call void @use(ptr noundef [[WIDE_PTR_PTR59]]) // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP66]], ptr align 8 [[OF]], i64 24, i1 false) -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR67:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP66]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR67:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP66]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR68:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR67]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR69:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP66]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR69:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP66]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB70:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR69]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR71:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP66]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR71:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP66]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB72:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR71]], align 8 // CHECK-NEXT: [[TMP32:%.*]] = getelementptr [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR68]], i64 1 // CHECK-NEXT: [[TMP33:%.*]] = icmp ule ptr [[TMP32]], [[WIDE_PTR_UB70]], !annotation [[META2]] -// CHECK-NEXT: br i1 [[TMP33]], label %[[CONT74:.*]], label %[[TRAP73:.*]], !prof [[PROF3]], !annotation [[META2]] +// CHECK-NEXT: br i1 [[TMP33]], label %[[CONT74:.*]], label %[[TRAP73:.*]], !annotation [[META2]] // CHECK: [[TRAP73]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META2]] // CHECK-NEXT: unreachable, !annotation [[META2]] // CHECK: [[CONT74]]: // CHECK-NEXT: [[TMP34:%.*]] = icmp ule ptr [[WIDE_PTR_LB72]], [[WIDE_PTR_PTR68]], !annotation [[META4]] -// CHECK-NEXT: br i1 [[TMP34]], label %[[CONT76:.*]], label %[[TRAP75:.*]], !prof [[PROF3]], !annotation [[META4]] +// CHECK-NEXT: br i1 [[TMP34]], label %[[CONT76:.*]], label %[[TRAP75:.*]], !annotation [[META4]] // CHECK: [[TRAP75]]: // CHECK-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4]], !annotation [[META4]] // CHECK-NEXT: unreachable, !annotation [[META4]] // CHECK: [[CONT76]]: -// CHECK-NEXT: [[F77:%.*]] = getelementptr inbounds nuw [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR68]], i32 0, i32 0 -// CHECK-NEXT: [[ARR78:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F77]], i32 0, i32 1 +// CHECK-NEXT: [[F77:%.*]] = getelementptr inbounds [[STRUCT_OUTER_FLEX_T]], ptr [[WIDE_PTR_PTR68]], i32 0, i32 0 +// CHECK-NEXT: [[ARR78:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[F77]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY79:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR78]], i64 0, i64 0 -// CHECK-NEXT: [[ARR81:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F77]], i32 0, i32 1 +// CHECK-NEXT: [[ARR81:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[F77]], i32 0, i32 1 // CHECK-NEXT: [[ARRAYDECAY82:%.*]] = getelementptr inbounds [0 x i8], ptr [[ARR81]], i64 0, i64 0 -// CHECK-NEXT: [[COUNT83:%.*]] = getelementptr inbounds nuw [[STRUCT_FLEX_T]], ptr [[F77]], i32 0, i32 0 +// CHECK-NEXT: [[COUNT83:%.*]] = getelementptr inbounds [[STRUCT_FLEX_T]], ptr [[F77]], i32 0, i32 0 // CHECK-NEXT: [[TMP35:%.*]] = load i32, ptr [[COUNT83]], align 4 // CHECK-NEXT: [[IDX_EXT84:%.*]] = sext i32 [[TMP35]] to i64 // CHECK-NEXT: [[ADD_PTR85:%.*]] = getelementptr inbounds i8, ptr [[ARRAYDECAY82]], i64 [[IDX_EXT84]] -// CHECK-NEXT: [[TMP36:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 0 +// CHECK-NEXT: [[TMP36:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 0 // CHECK-NEXT: store ptr [[F77]], ptr [[TMP36]], align 8 -// CHECK-NEXT: [[TMP37:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 1 +// CHECK-NEXT: [[TMP37:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 1 // CHECK-NEXT: store ptr [[ADD_PTR85]], ptr [[TMP37]], align 8 -// CHECK-NEXT: [[TMP38:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 2 +// CHECK-NEXT: [[TMP38:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 2 // CHECK-NEXT: store ptr [[F77]], ptr [[TMP38]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR86:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR86:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB87:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR86]], align 8 -// CHECK-NEXT: [[TMP39:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 0 +// CHECK-NEXT: [[TMP39:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 0 // CHECK-NEXT: store ptr [[WIDE_PTR_UB87]], ptr [[TMP39]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR88:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR88:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.2", ptr [[AGG_TEMP80]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR89:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR88]], align 8 -// CHECK-NEXT: [[TMP40:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 0 +// CHECK-NEXT: [[TMP40:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 0 // CHECK-NEXT: store ptr [[ARRAYDECAY79]], ptr [[TMP40]], align 8 -// CHECK-NEXT: [[TMP41:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 1 +// CHECK-NEXT: [[TMP41:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 1 // CHECK-NEXT: store ptr [[WIDE_PTR_PTR89]], ptr [[TMP41]], align 8 -// CHECK-NEXT: [[TMP42:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 2 +// CHECK-NEXT: [[TMP42:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 2 // CHECK-NEXT: store ptr [[ARRAYDECAY79]], ptr [[TMP42]], align 8 -// CHECK-NEXT: [[TMP43:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 0 +// CHECK-NEXT: [[TMP43:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 0 // CHECK-NEXT: [[TMP44:%.*]] = load ptr, ptr [[TMP43]], align 8 // CHECK-NEXT: [[BOUND_PTR_ARITH:%.*]] = getelementptr i8, ptr [[TMP44]], i64 0 -// CHECK-NEXT: [[TMP45:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 0 +// CHECK-NEXT: [[TMP45:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 0 // CHECK-NEXT: store ptr [[BOUND_PTR_ARITH]], ptr [[TMP45]], align 8 -// CHECK-NEXT: [[TMP46:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 1 +// CHECK-NEXT: [[TMP46:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 1 // CHECK-NEXT: [[TMP47:%.*]] = load ptr, ptr [[TMP46]], align 8 -// CHECK-NEXT: [[TMP48:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 1 +// CHECK-NEXT: [[TMP48:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 1 // CHECK-NEXT: store ptr [[TMP47]], ptr [[TMP48]], align 8 -// CHECK-NEXT: [[TMP49:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 2 +// CHECK-NEXT: [[TMP49:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[TMP]], i32 0, i32 2 // CHECK-NEXT: [[TMP50:%.*]] = load ptr, ptr [[TMP49]], align 8 -// CHECK-NEXT: [[TMP51:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 2 +// CHECK-NEXT: [[TMP51:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 2 // CHECK-NEXT: store ptr [[TMP50]], ptr [[TMP51]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR90:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR90:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR91:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR90]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR92:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR92:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB93:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR92]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR94:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR94:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.0", ptr [[AGG_TEMP65]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB95:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR94]], align 8 -// CHECK-NEXT: [[TMP52:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 0 +// CHECK-NEXT: [[TMP52:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 0 // CHECK-NEXT: store ptr [[WIDE_PTR_PTR91]], ptr [[TMP52]], align 8 -// CHECK-NEXT: [[TMP53:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 1 +// CHECK-NEXT: [[TMP53:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 1 // CHECK-NEXT: store ptr [[WIDE_PTR_UB93]], ptr [[TMP53]], align 8 -// CHECK-NEXT: [[TMP54:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 2 +// CHECK-NEXT: [[TMP54:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 2 // CHECK-NEXT: store ptr [[WIDE_PTR_LB95]], ptr [[TMP54]], align 8 -// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR96:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 0 +// CHECK-NEXT: [[WIDE_PTR_PTR_ADDR96:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 0 // CHECK-NEXT: [[WIDE_PTR_PTR97:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR96]], align 8 -// CHECK-NEXT: [[WIDE_PTR_UB_ADDR98:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 1 +// CHECK-NEXT: [[WIDE_PTR_UB_ADDR98:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 1 // CHECK-NEXT: [[WIDE_PTR_UB99:%.*]] = load ptr, ptr [[WIDE_PTR_UB_ADDR98]], align 8 -// CHECK-NEXT: [[WIDE_PTR_LB_ADDR100:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 2 +// CHECK-NEXT: [[WIDE_PTR_LB_ADDR100:%.*]] = getelementptr inbounds %"__bounds_safety::wide_ptr.bidi_indexable.1", ptr [[AGG_TEMP64]], i32 0, i32 2 // CHECK-NEXT: [[WIDE_PTR_LB101:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR100]], align 8 // CHECK-NEXT: call void @use(ptr noundef [[WIDE_PTR_PTR97]]) // CHECK-NEXT: ret void @@ -264,6 +264,5 @@ void process_frame(char *__counted_by(frame_size) frame, unsigned frame_size) { } //. // CHECK: [[META2]] = !{!"bounds-safety-check-ptr-lt-upper-bound"} -// CHECK: [[PROF3]] = !{!"branch_weights", i32 1048575, i32 1} // CHECK: [[META4]] = !{!"bounds-safety-check-ptr-ge-lower-bound"} //. diff --git a/clang/test/BoundsSafety/Profile/flexible-array-member-checks-code-coverage.c b/clang/test/BoundsSafety/Profile/flexible-array-member-checks-code-coverage.c index 6e57f5c59739f..9fb991ed67e01 100644 --- a/clang/test/BoundsSafety/Profile/flexible-array-member-checks-code-coverage.c +++ b/clang/test/BoundsSafety/Profile/flexible-array-member-checks-code-coverage.c @@ -18,28 +18,28 @@ void bar(struct s *p); // CHECK-NEXT: store i64 [[TMP0]], ptr @__profc_foo, align 8 // CHECK-NEXT: [[IDX_EXT:%.*]] = zext i32 [[SIZE]] to i64 // CHECK-NEXT: [[FLEX_BASE_NULL_CHECK_NOT:%.*]] = icmp eq ptr [[BUF]], null, {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[FLEX_BASE_NULL_CHECK_NOT]], label [[CONT41:%.*]], label [[FLEX_BASE_NONNULL:%.*]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[FLEX_BASE_NULL_CHECK_NOT]], label %[[CONT41:.*]], label [[FLEX_BASE_NONNULL:%.*]], {{!annotation ![0-9]+}} // CHECK: flex.base.nonnull: // CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[BUF]], i64 [[IDX_EXT]] // CHECK-NEXT: [[TMP1:%.*]] = getelementptr i8, ptr [[BUF]], i64 4 // CHECK-NEXT: [[DOTNOT:%.*]] = icmp ult ptr [[TMP1]], [[BUF]], {{!annotation ![0-9]+}} // CHECK-NEXT: [[DOTNOT51:%.*]] = icmp ugt ptr [[TMP1]], [[ADD_PTR]], {{!annotation ![0-9]+}} // CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[DOTNOT]], i1 true, i1 [[DOTNOT51]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[OR_COND]], label [[TRAP:%.*]], label [[CONT27:%.*]], {{!annotation ![0-9]+}} +// CHECK-NEXT: br i1 [[OR_COND]], label [[TRAP:%.*]], label %[[CONT27:.*]], {{!annotation ![0-9]+}} // CHECK: trap: // CHECK-NEXT: tail call void @llvm.ubsantrap(i8 25) #[[ATTR3:[0-9]+]], {{!annotation ![0-9]+}} // CHECK-NEXT: unreachable, {{!annotation ![0-9]+}} -// CHECK: cont27: +// CHECK: [[CONT27]]: // CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[BUF]], align 4, {{!tbaa ![0-9]+}} // CHECK-NEXT: [[FLEX_COUNT_MINUS:%.*]] = icmp sgt i32 [[TMP2]], -1, {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[FLEX_COUNT_MINUS]], label [[CONT30:%.*]], label [[TRAP]], {{!annotation ![0-9]+}} -// CHECK: cont30: +// CHECK-NEXT: br i1 [[FLEX_COUNT_MINUS]], label %[[CONT30:.*]], label [[TRAP]], {{!annotation ![0-9]+}} +// CHECK: [[CONT30]]: // CHECK-NEXT: [[GEPDIFF:%.*]] = add nsw i64 [[IDX_EXT]], -4, {{!annotation ![0-9]+}} // CHECK-NEXT: [[FLEX_AVAIL_COUNT_DIV:%.*]] = ashr exact i64 [[GEPDIFF]], 2, {{!annotation ![0-9]+}} // CHECK-NEXT: [[FLEX_COUNT_INTPTR:%.*]] = zext nneg i32 [[TMP2]] to i64, {{!annotation ![0-9]+}} // CHECK-NEXT: [[FLEX_COUNT_CHECK_NOT_NOT:%.*]] = icmp ult i64 [[FLEX_AVAIL_COUNT_DIV]], [[FLEX_COUNT_INTPTR]], {{!annotation ![0-9]+}} -// CHECK-NEXT: br i1 [[FLEX_COUNT_CHECK_NOT_NOT]], label [[TRAP]], label [[CONT41]], {{!annotation ![0-9]+}} -// CHECK: cont41: +// CHECK-NEXT: br i1 [[FLEX_COUNT_CHECK_NOT_NOT]], label [[TRAP]], label %[[CONT41]], {{!annotation ![0-9]+}} +// CHECK: [[CONT41]]: // CHECK-NEXT: tail call void @bar(ptr noundef [[BUF]]) #[[ATTR4:[0-9]+]] // CHECK-NEXT: ret void //