From cec82ccd5bb2e971d4d1724a658ee382c85748ee Mon Sep 17 00:00:00 2001 From: liusy58 Date: Tue, 3 Dec 2024 20:56:48 +0800 Subject: [PATCH] add --- .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 36 ++++++++++--------- .../CIR/CodeGen/address-space-conversion.cpp | 2 +- clang/test/CIR/CodeGen/clear_cache.c | 2 +- clang/test/CIR/CodeGen/initlist-ptr-ptr.cpp | 10 +++--- clang/test/CIR/CodeGen/pointer-arith-ext.c | 16 ++++----- clang/test/CIR/CodeGen/var-arg-float.c | 10 +++--- clang/test/CIR/CodeGen/var-arg-scope.c | 10 +++--- clang/test/CIR/CodeGen/var-arg.c | 10 +++--- clang/test/CIR/CodeGen/virtual-base-cast.cpp | 8 ++--- clang/test/CIR/Lowering/data-member.cir | 4 +-- clang/test/CIR/Lowering/dot.cir | 4 +-- clang/test/CIR/Lowering/globals.cir | 16 ++++----- clang/test/CIR/Lowering/ptrstride.cir | 4 +-- clang/test/CIR/Lowering/var-arg-x86_64.c | 26 +++++++------- 14 files changed, 80 insertions(+), 78 deletions(-) diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp index 2043457cf238..ee0f6d0fff91 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp @@ -607,7 +607,7 @@ lowerCirAttrAsValue(mlir::Operation *parentOp, cir::GlobalViewAttr globalAttr, auto resTy = addrOp.getType(); auto eltTy = converter->convertType(sourceType); addrOp = rewriter.create(loc, resTy, eltTy, addrOp, - indices, true); + indices, /*inbounds*/ true); } auto ptrTy = mlir::dyn_cast(globalAttr.getType()); @@ -874,8 +874,9 @@ mlir::LogicalResult CIRToLLVMBaseClassAddrOpLowering::matchAndRewrite( } if (baseClassOp.getAssumeNotNull()) { - rewriter.replaceOpWithNewOp( - baseClassOp, resultType, byteType, derivedAddr, offset); + rewriter.replaceOpWithNewOp(baseClassOp, resultType, + byteType, derivedAddr, + offset, /*inbounds*/ true); } else { auto loc = baseClassOp.getLoc(); mlir::Value isNull = rewriter.create( @@ -883,8 +884,8 @@ mlir::LogicalResult CIRToLLVMBaseClassAddrOpLowering::matchAndRewrite( rewriter.create(loc, derivedAddr.getType())); mlir::Value adjusted = rewriter.create( loc, resultType, byteType, derivedAddr, offset); - rewriter.replaceOpWithNewOp(baseClassOp, isNull, - derivedAddr, adjusted); + rewriter.replaceOpWithNewOp( + baseClassOp, isNull, derivedAddr, adjusted, /*inbounds*/ true); } return mlir::success(); } @@ -901,7 +902,8 @@ mlir::LogicalResult CIRToLLVMDerivedClassAddrOpLowering::matchAndRewrite( mlir::IntegerType::Signless); if (derivedClassOp.getAssumeNotNull()) { rewriter.replaceOpWithNewOp(derivedClassOp, resultType, - byteType, baseAddr, offset); + byteType, baseAddr, offset, + /*inbounds*/ true); } else { auto loc = derivedClassOp.getLoc(); mlir::Value isNull = rewriter.create( @@ -909,8 +911,8 @@ mlir::LogicalResult CIRToLLVMDerivedClassAddrOpLowering::matchAndRewrite( rewriter.create(loc, baseAddr.getType())); mlir::Value adjusted = rewriter.create( loc, resultType, byteType, baseAddr, offset); - rewriter.replaceOpWithNewOp(derivedClassOp, isNull, - baseAddr, adjusted); + rewriter.replaceOpWithNewOp( + derivedClassOp, isNull, baseAddr, adjusted, /*inbounds*/ true); } return mlir::success(); } @@ -975,8 +977,8 @@ mlir::LogicalResult CIRToLLVMVTTAddrPointOpLowering::matchAndRewrite( offsets.push_back(0); offsets.push_back(adaptor.getOffset()); } - rewriter.replaceOpWithNewOp(op, resultType, eltType, - llvmAddr, offsets, true); + rewriter.replaceOpWithNewOp( + op, resultType, eltType, llvmAddr, offsets, /*inbounds*/ true); return mlir::success(); } @@ -1033,7 +1035,7 @@ mlir::LogicalResult CIRToLLVMCastOpLowering::matchAndRewrite( auto elementTy = convertTy(ptrTy.getPointee()); auto offset = llvm::SmallVector{0}; rewriter.replaceOpWithNewOp( - castOp, targetType, elementTy, sourceValue, offset); + castOp, targetType, elementTy, sourceValue, offset, /*inbounds*/ true); break; } case cir::CastKind::int_to_bool: { @@ -3237,8 +3239,8 @@ mlir::LogicalResult CIRToLLVMGetMemberOpLowering::matchAndRewrite( // is always zero. The second offset tell us which member it will access. llvm::SmallVector offset{0, op.getIndex()}; const auto elementTy = getTypeConverter()->convertType(structTy); - rewriter.replaceOpWithNewOp(op, llResTy, elementTy, - adaptor.getAddr(), offset); + rewriter.replaceOpWithNewOp( + op, llResTy, elementTy, adaptor.getAddr(), offset, /*inbounds*/ true); return mlir::success(); } case cir::StructType::Union: @@ -3338,8 +3340,8 @@ mlir::LogicalResult CIRToLLVMVTableAddrPointOpLowering::matchAndRewrite( } assert(eltType && "Shouldn't ever be missing an eltType here"); - rewriter.replaceOpWithNewOp(op, targetType, eltType, - symAddr, offsets, true); + rewriter.replaceOpWithNewOp( + op, targetType, eltType, symAddr, offsets, /*inbounds*/ true); return mlir::success(); } @@ -3838,8 +3840,8 @@ mlir::LogicalResult CIRToLLVMPtrMaskOpLowering::matchAndRewrite( mlir::Value diff = rewriter.create(loc, intPtr, masked); rewriter.replaceOpWithNewOp( op, getTypeConverter()->convertType(op.getType()), - mlir::IntegerType::get(moduleOp->getContext(), 8), adaptor.getPtr(), - diff); + mlir::IntegerType::get(moduleOp->getContext(), 8), adaptor.getPtr(), diff, + /*inbounds*/ true); return mlir::success(); } diff --git a/clang/test/CIR/CodeGen/address-space-conversion.cpp b/clang/test/CIR/CodeGen/address-space-conversion.cpp index 1f4ee00ca63b..48b5a217ed63 100644 --- a/clang/test/CIR/CodeGen/address-space-conversion.cpp +++ b/clang/test/CIR/CodeGen/address-space-conversion.cpp @@ -62,7 +62,7 @@ void test_side_effect(pi1_t b) { // CIR: %[[#CAST:]] = cir.const #cir.ptr : !cir.ptr)> // CIR-NEXT: cir.store %[[#CAST]], %{{[0-9]+}} : !cir.ptr)>, !cir.ptr)>> - // LLVM: %{{[0-9]+}} = getelementptr i32, ptr addrspace(1) %{{[0-9]+}}, i64 1 + // LLVM: %{{[0-9]+}} = getelementptr inbounds i32, ptr addrspace(1) %{{[0-9]+}}, i64 1 // LLVM: store ptr addrspace(2) null, ptr %{{[0-9]+}}, align 8 } diff --git a/clang/test/CIR/CodeGen/clear_cache.c b/clang/test/CIR/CodeGen/clear_cache.c index 789d4708a814..ef249c71938b 100644 --- a/clang/test/CIR/CodeGen/clear_cache.c +++ b/clang/test/CIR/CodeGen/clear_cache.c @@ -20,7 +20,7 @@ char buffer[32] = "This is a largely unused buffer"; // CIR: cir.clear_cache %[[VAL_3]] : !cir.ptr, %[[VAL_8]], // LLVM-LABEL: main -// LLVM: call void @llvm.clear_cache(ptr @buffer, ptr getelementptr (i8, ptr @buffer, i64 32)) +// LLVM: call void @llvm.clear_cache(ptr @buffer, ptr getelementptr inbounds (i8, ptr @buffer, i64 32)) int main(void) { __builtin___clear_cache(buffer, buffer+32); diff --git a/clang/test/CIR/CodeGen/initlist-ptr-ptr.cpp b/clang/test/CIR/CodeGen/initlist-ptr-ptr.cpp index 8a0e2ac7aaab..f387320768d8 100644 --- a/clang/test/CIR/CodeGen/initlist-ptr-ptr.cpp +++ b/clang/test/CIR/CodeGen/initlist-ptr-ptr.cpp @@ -77,14 +77,14 @@ void test() { // LLVM: [[ELEM_ARRAY_PTR:%.*]] = alloca [2 x ptr], i64 1, align 8 // LLVM: br label %[[SCOPE_START:.*]] // LLVM: [[SCOPE_START]]: ; preds = %0 -// LLVM: [[PTR_FIRST_ELEM:%.*]] = getelementptr ptr, ptr [[ELEM_ARRAY_PTR]], i32 0 +// LLVM: [[PTR_FIRST_ELEM:%.*]] = getelementptr inbounds ptr, ptr [[ELEM_ARRAY_PTR]], i32 0 // LLVM: store ptr @.str, ptr [[PTR_FIRST_ELEM]], align 8 -// LLVM: [[PTR_SECOND_ELEM:%.*]] = getelementptr ptr, ptr [[PTR_FIRST_ELEM]], i64 1 +// LLVM: [[PTR_SECOND_ELEM:%.*]] = getelementptr inbounds ptr, ptr [[PTR_FIRST_ELEM]], i64 1 // LLVM: store ptr @.str.1, ptr [[PTR_SECOND_ELEM]], align 8 -// LLVM: [[INIT_START_FLD_PTR:%.*]] = getelementptr %"class.std::initializer_list", ptr [[INIT_STRUCT]], i32 0, i32 0 +// LLVM: [[INIT_START_FLD_PTR:%.*]] = getelementptr inbounds %"class.std::initializer_list", ptr [[INIT_STRUCT]], i32 0, i32 0 // LLVM: store ptr [[PTR_FIRST_ELEM]], ptr [[INIT_START_FLD_PTR]], align 8 -// LLVM: [[ELEM_ARRAY_END:%.*]] = getelementptr ptr, ptr [[PTR_FIRST_ELEM]], i64 2 -// LLVM: [[INIT_END_FLD_PTR:%.*]] = getelementptr %"class.std::initializer_list", ptr [[INIT_STRUCT]], i32 0, i32 1 +// LLVM: [[ELEM_ARRAY_END:%.*]] = getelementptr inbounds ptr, ptr [[PTR_FIRST_ELEM]], i64 2 +// LLVM: [[INIT_END_FLD_PTR:%.*]] = getelementptr inbounds %"class.std::initializer_list", ptr [[INIT_STRUCT]], i32 0, i32 1 // LLVM: store ptr [[ELEM_ARRAY_END]], ptr [[INIT_END_FLD_PTR]], align 8 // LLVM: [[ARG2PASS:%.*]] = load %"class.std::initializer_list", ptr [[INIT_STRUCT]], align 8 // LLVM: call void @_ZSt1fIPKcEvSt16initializer_listIT_E(%"class.std::initializer_list" [[ARG2PASS]]) diff --git a/clang/test/CIR/CodeGen/pointer-arith-ext.c b/clang/test/CIR/CodeGen/pointer-arith-ext.c index 558ad823cae4..56d5cc0f5364 100644 --- a/clang/test/CIR/CodeGen/pointer-arith-ext.c +++ b/clang/test/CIR/CodeGen/pointer-arith-ext.c @@ -15,7 +15,7 @@ void *f2(void *a, int b) { return a + b; } // LLVM: %[[PTR:.*]] = load ptr, ptr {{.*}}, align 8 // LLVM: %[[TOEXT:.*]] = load i32, ptr {{.*}}, align 4 // LLVM: %[[STRIDE:.*]] = sext i32 %[[TOEXT]] to i64 -// LLVM: getelementptr i8, ptr %[[PTR]], i64 %[[STRIDE]] +// LLVM: getelementptr inbounds i8, ptr %[[PTR]], i64 %[[STRIDE]] // These test the same paths above, just make sure it does not crash. void *f2_0(void *a, int b) { return &a[b]; } @@ -28,7 +28,7 @@ void *f3_1(int a, void *b) { return (a += b); } // CIR: cir.cast(ptr_to_int, %[[NEW_PTR]] : !cir.ptr), !s32i // LLVM-LABEL: @f3_1 -// LLVM: %[[NEW_PTR:.*]] = getelementptr +// LLVM: %[[NEW_PTR:.*]] = getelementptr inbounds // LLVM: ptrtoint ptr %[[NEW_PTR]] to i32 void *f4(void *a, int b) { return a - b; } @@ -43,7 +43,7 @@ void *f4(void *a, int b) { return a - b; } // LLVM: %[[TOEXT:.*]] = load i32, ptr {{.*}}, align 4 // LLVM: %[[STRIDE:.*]] = sext i32 %[[TOEXT]] to i64 // LLVM: %[[SUB:.*]] = sub i64 0, %[[STRIDE]] -// LLVM: getelementptr i8, ptr %[[PTR]], i64 %[[SUB]] +// LLVM: getelementptr inbounds i8, ptr %[[PTR]], i64 %[[SUB]] // Similar to f4, just make sure it does not crash. void *f4_1(void *a, int b) { return (a -= b); } @@ -58,7 +58,7 @@ FP f5(FP a, int b) { return a + b; } // LLVM: %[[PTR:.*]] = load ptr, ptr {{.*}}, align 8 // LLVM: %[[TOEXT:.*]] = load i32, ptr {{.*}}, align 4 // LLVM: %[[STRIDE:.*]] = sext i32 %[[TOEXT]] to i64 -// LLVM: getelementptr i8, ptr %[[PTR]], i64 %[[STRIDE]] +// LLVM: getelementptr inbounds i8, ptr %[[PTR]], i64 %[[STRIDE]] // These test the same paths above, just make sure it does not crash. FP f5_1(FP a, int b) { return (a += b); } @@ -77,7 +77,7 @@ FP f7(FP a, int b) { return a - b; } // LLVM: %[[TOEXT:.*]] = load i32, ptr {{.*}}, align 4 // LLVM: %[[STRIDE:.*]] = sext i32 %[[TOEXT]] to i64 // LLVM: %[[SUB:.*]] = sub i64 0, %[[STRIDE]] -// LLVM: getelementptr i8, ptr %[[PTR]], i64 %[[SUB]] +// LLVM: getelementptr inbounds i8, ptr %[[PTR]], i64 %[[SUB]] // Similar to f7, just make sure it does not crash. FP f7_1(FP a, int b) { return (a -= b); } @@ -93,7 +93,7 @@ void f8(void *a, int b) { return *(a + b); } // LLVM: %[[PTR:.*]] = load ptr, ptr {{.*}}, align 8 // LLVM: %[[TOEXT:.*]] = load i32, ptr {{.*}}, align 4 // LLVM: %[[STRIDE:.*]] = sext i32 %[[TOEXT]] to i64 -// LLVM: getelementptr i8, ptr %[[PTR]], i64 %[[STRIDE]] +// LLVM: getelementptr inbounds i8, ptr %[[PTR]], i64 %[[STRIDE]] // LLVM: ret void void f8_1(void *a, int b) { return a[b]; } @@ -107,7 +107,7 @@ void f8_1(void *a, int b) { return a[b]; } // LLVM: %[[PTR:.*]] = load ptr, ptr {{.*}}, align 8 // LLVM: %[[TOEXT:.*]] = load i32, ptr {{.*}}, align 4 // LLVM: %[[STRIDE:.*]] = sext i32 %[[TOEXT]] to i64 -// LLVM: getelementptr i8, ptr %[[PTR]], i64 %[[STRIDE]] +// LLVM: getelementptr inbounds i8, ptr %[[PTR]], i64 %[[STRIDE]] // LLVM: ret void unsigned char *p(unsigned int x) { @@ -121,4 +121,4 @@ unsigned char *p(unsigned int x) { // CIR: cir.ptr_stride({{.*}} : !cir.ptr, %[[SUB]] : !u32i), !cir.ptr // LLVM-LABEL: @p -// LLVM: getelementptr i8, ptr {{.*}} +// LLVM: getelementptr inbounds i8, ptr {{.*}} diff --git a/clang/test/CIR/CodeGen/var-arg-float.c b/clang/test/CIR/CodeGen/var-arg-float.c index 5b8539cfa380..b217d5017661 100644 --- a/clang/test/CIR/CodeGen/var-arg-float.c +++ b/clang/test/CIR/CodeGen/var-arg-float.c @@ -82,7 +82,7 @@ double f1(int n, ...) { // LLVM: [[RETP:%.*]] = alloca double, i64 1, align 8 // LLVM: [[RESP:%.*]] = alloca double, i64 1, align 8 // LLVM: call void @llvm.va_start.p0(ptr [[VARLIST:%.*]]) -// LLVM: [[VR_OFFS_P:%.*]] = getelementptr %struct.__va_list, ptr [[VARLIST]], i32 0, i32 4 +// LLVM: [[VR_OFFS_P:%.*]] = getelementptr inbounds %struct.__va_list, ptr [[VARLIST]], i32 0, i32 4 // LLVM: [[VR_OFFS:%.*]] = load i32, ptr [[VR_OFFS_P]], align 4 // LLVM-NEXT: [[CMP0:%.*]] = icmp sge i32 [[VR_OFFS]], 0 // LLVM-NEXT: br i1 [[CMP0]], label %[[BB_ON_STACK:.*]], label %[[BB_MAY_REG:.*]] @@ -94,16 +94,16 @@ double f1(int n, ...) { // LLVM-NEXT: br i1 [[CMP1]], label %[[BB_IN_REG:.*]], label %[[BB_ON_STACK]] // LLVM: [[BB_IN_REG]]: ; -// LLVM-NEXT: [[VR_TOP_P:%.*]] = getelementptr %struct.__va_list, ptr [[VARLIST]], i32 0, i32 2 +// LLVM-NEXT: [[VR_TOP_P:%.*]] = getelementptr inbounds %struct.__va_list, ptr [[VARLIST]], i32 0, i32 2 // LLVM-NEXT: [[VR_TOP:%.*]] = load ptr, ptr [[VR_TOP_P]], align 8 // LLVM-NEXT: [[EXT64_VR_OFFS:%.*]] = sext i32 [[VR_OFFS]] to i64 -// LLVM-NEXT: [[IN_REG_OUTPUT:%.*]] = getelementptr i8, ptr [[VR_TOP]], i64 [[EXT64_VR_OFFS]] +// LLVM-NEXT: [[IN_REG_OUTPUT:%.*]] = getelementptr inbounds i8, ptr [[VR_TOP]], i64 [[EXT64_VR_OFFS]] // LLVM-NEXT: br label %[[BB_END:.*]] // LLVM: [[BB_ON_STACK]]: ; -// LLVM-NEXT: [[STACK_P:%.*]] = getelementptr %struct.__va_list, ptr [[VARLIST]], i32 0, i32 0 +// LLVM-NEXT: [[STACK_P:%.*]] = getelementptr inbounds %struct.__va_list, ptr [[VARLIST]], i32 0, i32 0 // LLVM-NEXT: [[STACK_V:%.*]] = load ptr, ptr [[STACK_P]], align 8 -// LLVM-NEXT: [[NEW_STACK_V:%.*]] = getelementptr i8, ptr [[STACK_V]], i64 8 +// LLVM-NEXT: [[NEW_STACK_V:%.*]] = getelementptr inbounds i8, ptr [[STACK_V]], i64 8 // LLVM-NEXT: store ptr [[NEW_STACK_V]], ptr [[STACK_P]], align 8 // LLVM-NEXT: br label %[[BB_END]] diff --git a/clang/test/CIR/CodeGen/var-arg-scope.c b/clang/test/CIR/CodeGen/var-arg-scope.c index a57fcb9f1944..66abe65627ae 100644 --- a/clang/test/CIR/CodeGen/var-arg-scope.c +++ b/clang/test/CIR/CodeGen/var-arg-scope.c @@ -71,7 +71,7 @@ void f1(__builtin_va_list c) { // LLVM: br label %[[SCOPE_FRONT:.*]] // LLVM: [[SCOPE_FRONT]]: ; preds = %1 -// LLVM: [[GR_OFFS_P:%.*]] = getelementptr %struct.__va_list, ptr [[VARLIST]], i32 0, i32 3 +// LLVM: [[GR_OFFS_P:%.*]] = getelementptr inbounds %struct.__va_list, ptr [[VARLIST]], i32 0, i32 3 // LLVM: [[GR_OFFS:%.*]] = load i32, ptr [[GR_OFFS_P]], align 4 // LLVM-NEXT: [[CMP0:%.*]] = icmp sge i32 [[GR_OFFS]], 0 // LLVM-NEXT: br i1 [[CMP0]], label %[[BB_ON_STACK:.*]], label %[[BB_MAY_REG:.*]] @@ -83,16 +83,16 @@ void f1(__builtin_va_list c) { // LLVM-NEXT: br i1 [[CMP1]], label %[[BB_IN_REG:.*]], label %[[BB_ON_STACK]] // LLVM: [[BB_IN_REG]]: ; -// LLVM-NEXT: [[GR_TOP_P:%.*]] = getelementptr %struct.__va_list, ptr [[VARLIST]], i32 0, i32 1 +// LLVM-NEXT: [[GR_TOP_P:%.*]] = getelementptr inbounds %struct.__va_list, ptr [[VARLIST]], i32 0, i32 1 // LLVM-NEXT: [[GR_TOP:%.*]] = load ptr, ptr [[GR_TOP_P]], align 8 // LLVM-NEXT: [[EXT64_GR_OFFS:%.*]] = sext i32 [[GR_OFFS]] to i64 -// LLVM-NEXT: [[IN_REG_OUTPUT:%.*]] = getelementptr i8, ptr [[GR_TOP]], i64 [[EXT64_GR_OFFS]] +// LLVM-NEXT: [[IN_REG_OUTPUT:%.*]] = getelementptr inbounds i8, ptr [[GR_TOP]], i64 [[EXT64_GR_OFFS]] // LLVM-NEXT: br label %[[BB_END:.*]] // LLVM: [[BB_ON_STACK]]: ; -// LLVM-NEXT: [[STACK_P:%.*]] = getelementptr %struct.__va_list, ptr [[VARLIST]], i32 0, i32 0 +// LLVM-NEXT: [[STACK_P:%.*]] = getelementptr inbounds %struct.__va_list, ptr [[VARLIST]], i32 0, i32 0 // LLVM-NEXT: [[STACK_V:%.*]] = load ptr, ptr [[STACK_P]], align 8 -// LLVM-NEXT: [[NEW_STACK_V:%.*]] = getelementptr i8, ptr [[STACK_V]], i64 8 +// LLVM-NEXT: [[NEW_STACK_V:%.*]] = getelementptr inbounds i8, ptr [[STACK_V]], i64 8 // LLVM-NEXT: store ptr [[NEW_STACK_V]], ptr [[STACK_P]], align 8 // LLVM-NEXT: br label %[[BB_END]] diff --git a/clang/test/CIR/CodeGen/var-arg.c b/clang/test/CIR/CodeGen/var-arg.c index b2f1161fa443..23bf7de58555 100644 --- a/clang/test/CIR/CodeGen/var-arg.c +++ b/clang/test/CIR/CodeGen/var-arg.c @@ -85,7 +85,7 @@ int f1(int n, ...) { // LLVM: [[RETP:%.*]] = alloca i32, i64 1, align 4 // LLVM: [[RESP:%.*]] = alloca i32, i64 1, align 4 // LLVM: call void @llvm.va_start.p0(ptr [[VARLIST:%.*]]) -// LLVM: [[GR_OFFS_P:%.*]] = getelementptr %struct.__va_list, ptr [[VARLIST]], i32 0, i32 3 +// LLVM: [[GR_OFFS_P:%.*]] = getelementptr inbounds %struct.__va_list, ptr [[VARLIST]], i32 0, i32 3 // LLVM: [[GR_OFFS:%.*]] = load i32, ptr [[GR_OFFS_P]], align 4 // LLVM-NEXT: [[CMP0:%.*]] = icmp sge i32 [[GR_OFFS]], 0 // LLVM-NEXT: br i1 [[CMP0]], label %[[BB_ON_STACK:.*]], label %[[BB_MAY_REG:.*]] @@ -97,16 +97,16 @@ int f1(int n, ...) { // LLVM-NEXT: br i1 [[CMP1]], label %[[BB_IN_REG:.*]], label %[[BB_ON_STACK]] // LLVM: [[BB_IN_REG]]: ; -// LLVM-NEXT: [[GR_TOP_P:%.*]] = getelementptr %struct.__va_list, ptr [[VARLIST]], i32 0, i32 1 +// LLVM-NEXT: [[GR_TOP_P:%.*]] = getelementptr inbounds %struct.__va_list, ptr [[VARLIST]], i32 0, i32 1 // LLVM-NEXT: [[GR_TOP:%.*]] = load ptr, ptr [[GR_TOP_P]], align 8 // LLVM-NEXT: [[EXT64_GR_OFFS:%.*]] = sext i32 [[GR_OFFS]] to i64 -// LLVM-NEXT: [[IN_REG_OUTPUT:%.*]] = getelementptr i8, ptr [[GR_TOP]], i64 [[EXT64_GR_OFFS]] +// LLVM-NEXT: [[IN_REG_OUTPUT:%.*]] = getelementptr inbounds i8, ptr [[GR_TOP]], i64 [[EXT64_GR_OFFS]] // LLVM-NEXT: br label %[[BB_END:.*]] // LLVM: [[BB_ON_STACK]]: ; -// LLVM-NEXT: [[STACK_P:%.*]] = getelementptr %struct.__va_list, ptr [[VARLIST]], i32 0, i32 0 +// LLVM-NEXT: [[STACK_P:%.*]] = getelementptr inbounds %struct.__va_list, ptr [[VARLIST]], i32 0, i32 0 // LLVM-NEXT: [[STACK_V:%.*]] = load ptr, ptr [[STACK_P]], align 8 -// LLVM-NEXT: [[NEW_STACK_V:%.*]] = getelementptr i8, ptr [[STACK_V]], i64 8 +// LLVM-NEXT: [[NEW_STACK_V:%.*]] = getelementptr inbounds i8, ptr [[STACK_V]], i64 8 // LLVM-NEXT: store ptr [[NEW_STACK_V]], ptr [[STACK_P]], align 8 // LLVM-NEXT: br label %[[BB_END]] diff --git a/clang/test/CIR/CodeGen/virtual-base-cast.cpp b/clang/test/CIR/CodeGen/virtual-base-cast.cpp index 2c2a3e378714..11b4598e073d 100644 --- a/clang/test/CIR/CodeGen/virtual-base-cast.cpp +++ b/clang/test/CIR/CodeGen/virtual-base-cast.cpp @@ -25,9 +25,9 @@ A* a() { return x; } // FIXME: this version should include null check. // LLVM-LABEL: @_Z1av() -// LLVM: %[[OFFSET_OFFSET:.*]] = getelementptr i8, ptr {{.*}}, i64 -32 +// LLVM: %[[OFFSET_OFFSET:.*]] = getelementptr inbounds i8, ptr {{.*}}, i64 -32 // LLVM: %[[OFFSET_PTR:.*]] = load i64, ptr %[[OFFSET_OFFSET]], align 8 -// LLVM: %[[VBASE_ADDR:.*]] = getelementptr i8, ptr {{.*}}, i64 %[[OFFSET_PTR]] +// LLVM: %[[VBASE_ADDR:.*]] = getelementptr inbounds i8, ptr {{.*}}, i64 %[[OFFSET_PTR]] // LLVM: store ptr %[[VBASE_ADDR]], ptr {{.*}}, align 8 B* b() { return x; } @@ -46,8 +46,8 @@ BB* d() { return y; } // CIR: cir.binop(add, %[[OFFSET]], %[[ADJUST]]) : !s64i // LLVM-LABEL: @_Z1dv -// LLVM: %[[OFFSET_OFFSET:.*]] = getelementptr i8, ptr {{.*}}, i64 -48 +// LLVM: %[[OFFSET_OFFSET:.*]] = getelementptr inbounds i8, ptr {{.*}}, i64 -48 // LLVM: %[[OFFSET_PTR:.*]] = load i64, ptr %[[OFFSET_OFFSET]], align 8 // LLVM: %[[ADJUST:.*]] = add i64 %[[OFFSET_PTR]], 16 -// LLVM: %[[VBASE_ADDR:.*]] = getelementptr i8, ptr {{.*}}, i64 %[[ADJUST]] +// LLVM: %[[VBASE_ADDR:.*]] = getelementptr inbounds i8, ptr {{.*}}, i64 %[[ADJUST]] // LLVM: store ptr %[[VBASE_ADDR]], \ No newline at end of file diff --git a/clang/test/CIR/Lowering/data-member.cir b/clang/test/CIR/Lowering/data-member.cir index 14f3138bde56..bed2fed47f2d 100644 --- a/clang/test/CIR/Lowering/data-member.cir +++ b/clang/test/CIR/Lowering/data-member.cir @@ -45,13 +45,13 @@ module @test attributes { } // MLIR: llvm.func @get_runtime_member(%[[ARG0:.+]]: !llvm.ptr, %[[ARG1:.+]]: i64) -> !llvm.ptr // MLIR-NEXT: %[[#PTR:]] = llvm.bitcast %[[ARG0]] : !llvm.ptr to !llvm.ptr - // MLIR-NEXT: %[[#VAL:]] = llvm.getelementptr %[[#PTR]][%[[ARG1]]] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + // MLIR-NEXT: %[[#VAL:]] = llvm.getelementptr inbounds %[[#PTR]][%[[ARG1]]] : (!llvm.ptr, i64) -> !llvm.ptr, i8 // MLIR-NEXT: %[[#RET:]] = llvm.bitcast %[[#VAL]] : !llvm.ptr to !llvm.ptr // MLIR-NEXT: llvm.return %[[#RET]] : !llvm.ptr // MLIR-NEXT: } // LLVM: define ptr @get_runtime_member(ptr %[[ARG0:.+]], i64 %[[ARG1:.+]]) - // LLVM-NEXT: %[[#VAL:]] = getelementptr i8, ptr %[[ARG0]], i64 %[[ARG1]] + // LLVM-NEXT: %[[#VAL:]] = getelementptr inbounds i8, ptr %[[ARG0]], i64 %[[ARG1]] // LLVM-NEXT: ret ptr %[[#VAL]] // LLVM-NEXT: } } \ No newline at end of file diff --git a/clang/test/CIR/Lowering/dot.cir b/clang/test/CIR/Lowering/dot.cir index 4c1586d8eaa5..aae7f84b01eb 100644 --- a/clang/test/CIR/Lowering/dot.cir +++ b/clang/test/CIR/Lowering/dot.cir @@ -83,12 +83,12 @@ module { // MLIR: %[[VAL_23:.*]] = llvm.load %[[VAL_4]] {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr // MLIR: %[[VAL_24:.*]] = llvm.load %[[VAL_2]] {alignment = 4 : i64} : !llvm.ptr -> i32 // MLIR: %[[VAL_25:.*]] = llvm.sext %[[VAL_24]] : i32 to i64 -// MLIR: %[[VAL_26:.*]] = llvm.getelementptr %[[VAL_23]]{{\[}}%[[VAL_25]]] : (!llvm.ptr, i64) -> !llvm.ptr, f64 +// MLIR: %[[VAL_26:.*]] = llvm.getelementptr inbounds %[[VAL_23]]{{\[}}%[[VAL_25]]] : (!llvm.ptr, i64) -> !llvm.ptr, f64 // MLIR: %[[VAL_27:.*]] = llvm.load %[[VAL_26]] {alignment = 8 : i64} : !llvm.ptr -> f64 // MLIR: %[[VAL_28:.*]] = llvm.load %[[VAL_6]] {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr // MLIR: %[[VAL_29:.*]] = llvm.load %[[VAL_2]] {alignment = 4 : i64} : !llvm.ptr -> i32 // MLIR: %[[VAL_30:.*]] = llvm.sext %[[VAL_29]] : i32 to i64 -// MLIR: %[[VAL_31:.*]] = llvm.getelementptr %[[VAL_28]]{{\[}}%[[VAL_30]]] : (!llvm.ptr, i64) -> !llvm.ptr, f64 +// MLIR: %[[VAL_31:.*]] = llvm.getelementptr inbounds %[[VAL_28]]{{\[}}%[[VAL_30]]] : (!llvm.ptr, i64) -> !llvm.ptr, f64 // MLIR: %[[VAL_32:.*]] = llvm.load %[[VAL_31]] {alignment = 8 : i64} : !llvm.ptr -> f64 // MLIR: %[[VAL_33:.*]] = llvm.fmul %[[VAL_27]], %[[VAL_32]] : f64 // MLIR: %[[VAL_34:.*]] = llvm.load %[[VAL_12]] {alignment = 8 : i64} : !llvm.ptr -> f64 diff --git a/clang/test/CIR/Lowering/globals.cir b/clang/test/CIR/Lowering/globals.cir index 765544e8c125..6e565a2e58bd 100644 --- a/clang/test/CIR/Lowering/globals.cir +++ b/clang/test/CIR/Lowering/globals.cir @@ -107,27 +107,27 @@ module { %5 = cir.get_global @string : !cir.ptr> %6 = cir.cast(array_to_ptrdecay, %5 : !cir.ptr>), !cir.ptr // MLIR: %[[RES:[0-9]+]] = llvm.mlir.addressof @string : !llvm.ptr - // MLIR: %{{[0-9]+}} = llvm.getelementptr %[[RES]][0] : (!llvm.ptr) -> !llvm.ptr, i8 + // MLIR: %{{[0-9]+}} = llvm.getelementptr inbounds %[[RES]][0] : (!llvm.ptr) -> !llvm.ptr, i8 cir.store %6, %0 : !cir.ptr, !cir.ptr> %7 = cir.get_global @uint : !cir.ptr> %8 = cir.cast(array_to_ptrdecay, %7 : !cir.ptr>), !cir.ptr // MLIR: %[[RES:[0-9]+]] = llvm.mlir.addressof @uint : !llvm.ptr - // MLIR: %{{[0-9]+}} = llvm.getelementptr %[[RES]][0] : (!llvm.ptr) -> !llvm.ptr, i32 + // MLIR: %{{[0-9]+}} = llvm.getelementptr inbounds %[[RES]][0] : (!llvm.ptr) -> !llvm.ptr, i32 cir.store %8, %1 : !cir.ptr, !cir.ptr> %9 = cir.get_global @sshort : !cir.ptr> %10 = cir.cast(array_to_ptrdecay, %9 : !cir.ptr>), !cir.ptr // MLIR: %[[RES:[0-9]+]] = llvm.mlir.addressof @sshort : !llvm.ptr - // MLIR: %{{[0-9]+}} = llvm.getelementptr %[[RES]][0] : (!llvm.ptr) -> !llvm.ptr, i16 + // MLIR: %{{[0-9]+}} = llvm.getelementptr inbounds %[[RES]][0] : (!llvm.ptr) -> !llvm.ptr, i16 cir.store %10, %2 : !cir.ptr, !cir.ptr> %11 = cir.get_global @sint : !cir.ptr> %12 = cir.cast(array_to_ptrdecay, %11 : !cir.ptr>), !cir.ptr // MLIR: %[[RES:[0-9]+]] = llvm.mlir.addressof @sint : !llvm.ptr - // MLIR: %{{[0-9]+}} = llvm.getelementptr %[[RES]][0] : (!llvm.ptr) -> !llvm.ptr, i32 + // MLIR: %{{[0-9]+}} = llvm.getelementptr inbounds %[[RES]][0] : (!llvm.ptr) -> !llvm.ptr, i32 cir.store %12, %3 : !cir.ptr, !cir.ptr> %13 = cir.get_global @ll : !cir.ptr> %14 = cir.cast(array_to_ptrdecay, %13 : !cir.ptr>), !cir.ptr // MLIR: %[[RES:[0-9]+]] = llvm.mlir.addressof @ll : !llvm.ptr - // MLIR: %{{[0-9]+}} = llvm.getelementptr %[[RES]][0] : (!llvm.ptr) -> !llvm.ptr, i64 + // MLIR: %{{[0-9]+}} = llvm.getelementptr inbounds %[[RES]][0] : (!llvm.ptr) -> !llvm.ptr, i64 cir.store %14, %4 : !cir.ptr, !cir.ptr> cir.return } @@ -181,10 +181,10 @@ module { //MLIR-LABEL: @foo //MLIR: %[[RES4:.*]] = llvm.mlir.addressof @Handlers : !llvm.ptr //MLIR: %[[LOAD:.*]] = llvm.load {{.*}} {alignment = 4 : i64} : !llvm.ptr -> i32 - //MLIR: %[[RES6:.*]] = llvm.getelementptr %[[RES4]][0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<"struct.anon.1", (ptr)> + //MLIR: %[[RES6:.*]] = llvm.getelementptr inbounds %[[RES4]][0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<"struct.anon.1", (ptr)> //MLIR: %[[RES5:.*]] = llvm.sext %[[LOAD]] : i32 to i64 - //MLIR: %[[RES7:.*]] = llvm.getelementptr %[[RES6]][%[[RES5]]] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct.anon.1", (ptr)> - //MLIR: %[[RES8:.*]] = llvm.getelementptr %[[RES7]][0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<"struct.anon.1", (ptr)> + //MLIR: %[[RES7:.*]] = llvm.getelementptr inbounds %[[RES6]][%[[RES5]]] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct.anon.1", (ptr)> + //MLIR: %[[RES8:.*]] = llvm.getelementptr inbounds %[[RES7]][0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<"struct.anon.1", (ptr)> //MLIR: %[[RES9:.*]] = llvm.load %[[RES8]] {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr //MLIR: llvm.call %[[RES9]]({{.*}}) : !llvm.ptr, (i32) -> () diff --git a/clang/test/CIR/Lowering/ptrstride.cir b/clang/test/CIR/Lowering/ptrstride.cir index b5df897d2b0e..b3ee2e638a40 100644 --- a/clang/test/CIR/Lowering/ptrstride.cir +++ b/clang/test/CIR/Lowering/ptrstride.cir @@ -25,10 +25,10 @@ module { // MLIR: %[[VAL_3:.*]] = llvm.load %[[VAL_2]] {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr // MLIR: %[[VAL_4:.*]] = llvm.mlir.constant(1 : i32) : i32 // MLIR: %[[VAL_5:.*]] = llvm.sext %[[VAL_4]] : i32 to i64 -// MLIR: %[[VAL_6:.*]] = llvm.getelementptr %[[VAL_3]]{{\[}}%[[VAL_5]]] : (!llvm.ptr, i64) -> !llvm.ptr, i32 +// MLIR: %[[VAL_6:.*]] = llvm.getelementptr inbounds %[[VAL_3]]{{\[}}%[[VAL_5]]] : (!llvm.ptr, i64) -> !llvm.ptr, i32 // MLIR: %[[VAL_7:.*]] = llvm.load %[[VAL_6]] {alignment = 4 : i64} : !llvm.ptr -> i32 // MLIR: llvm.return // MLIR-LABEL: @g // MLIR: %0 = llvm.sext %arg1 : i32 to i64 -// MLIR-NEXT: llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 +// MLIR-NEXT: llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 diff --git a/clang/test/CIR/Lowering/var-arg-x86_64.c b/clang/test/CIR/Lowering/var-arg-x86_64.c index 977d938dbb1b..a66df3bff0d1 100644 --- a/clang/test/CIR/Lowering/var-arg-x86_64.c +++ b/clang/test/CIR/Lowering/var-arg-x86_64.c @@ -17,10 +17,10 @@ double f1(int n, ...) { // CHECK: define {{.*}}@f1 // CHECK: [[VA_LIST_ALLOCA:%.+]] = alloca {{.*}}[[VA_LIST_TYPE]] -// CHECK: [[VA_LIST:%.+]] = getelementptr {{.*}} [[VA_LIST_ALLOCA]], i32 0 +// CHECK: [[VA_LIST:%.+]] = getelementptr inbounds {{.*}} [[VA_LIST_ALLOCA]], i32 0 // CHECK: call {{.*}}@llvm.va_start.p0(ptr [[VA_LIST]]) -// CHECK: [[VA_LIST2:%.+]] = getelementptr {{.*}} [[VA_LIST_ALLOCA]], i32 0 -// CHECK: [[FP_OFFSET_P:%.+]] = getelementptr {{.*}} [[VA_LIST2]], i32 0, i32 1 +// CHECK: [[VA_LIST2:%.+]] = getelementptr inbounds {{.*}} [[VA_LIST_ALLOCA]], i32 0 +// CHECK: [[FP_OFFSET_P:%.+]] = getelementptr inbounds {{.*}} [[VA_LIST2]], i32 0, i32 1 // CHECK: [[FP_OFFSET:%.+]] = load {{.*}}, ptr [[FP_OFFSET_P]] // CHECK: [[COMPARED:%.+]] = icmp ule i32 {{.*}}, 160 // CHECK: br i1 [[COMPARED]], label %[[THEN_BB:.+]], label %[[ELSE_BB:.+]] @@ -31,14 +31,14 @@ double f1(int n, ...) { // CHECK: br label %[[CONT_BB:.+]] // // CHECK: [[ELSE_BB]]: -// CHECK: [[OVERFLOW_ARG_AREA_ADDR:%.+]] = getelementptr {{.*}} [[VA_LIST2]], i32 0, i32 2 +// CHECK: [[OVERFLOW_ARG_AREA_ADDR:%.+]] = getelementptr inbounds {{.*}} [[VA_LIST2]], i32 0, i32 2 // CHECK: [[OVERFLOW_ARG_AREA:%.+]] = load ptr, ptr [[OVERFLOW_ARG_AREA_ADDR]] -// CHECK: [[OVERFLOW_ARG_AREA_OFFSET:%.+]] = getelementptr {{.*}} [[OVERFLOW_ARG_AREA]], i64 8 +// CHECK: [[OVERFLOW_ARG_AREA_OFFSET:%.+]] = getelementptr inbounds {{.*}} [[OVERFLOW_ARG_AREA]], i64 8 // CHECK: store ptr [[OVERFLOW_ARG_AREA_OFFSET]], ptr [[OVERFLOW_ARG_AREA_ADDR]] // CHECK: br label %[[CONT_BB]] // // CHECK: [[CONT_BB]]: -// CHECK: [[VA_LIST3:%.+]] = getelementptr {{.*}} [[VA_LIST_ALLOCA]], i32 0 +// CHECK: [[VA_LIST3:%.+]] = getelementptr inbounds {{.*}} [[VA_LIST_ALLOCA]], i32 0 // CHECK: call {{.*}}@llvm.va_end.p0(ptr [[VA_LIST3]]) // CIR: cir.func @f1 @@ -88,22 +88,22 @@ long double f2(int n, ...) { // CHECK: [[RESULT:%.+]] = alloca x86_fp80 // CHECK: [[VA_LIST_ALLOCA:%.+]] = alloca {{.*}}[[VA_LIST_TYPE]] // CHECK: [[RES:%.+]] = alloca x86_fp80 -// CHECK: [[VA_LIST:%.+]] = getelementptr {{.*}} [[VA_LIST_ALLOCA]], i32 0 +// CHECK: [[VA_LIST:%.+]] = getelementptr inbounds {{.*}} [[VA_LIST_ALLOCA]], i32 0 // CHECK: call {{.*}}@llvm.va_start.p0(ptr [[VA_LIST]]) -// CHECK: [[VA_LIST2:%.+]] = getelementptr {{.*}} [[VA_LIST_ALLOCA]], i32 0 -// CHECK: [[OVERFLOW_AREA_P:%.+]] = getelementptr {{.*}} [[VA_LIST2]], i32 0, i32 2 +// CHECK: [[VA_LIST2:%.+]] = getelementptr inbounds {{.*}} [[VA_LIST_ALLOCA]], i32 0 +// CHECK: [[OVERFLOW_AREA_P:%.+]] = getelementptr inbounds {{.*}} [[VA_LIST2]], i32 0, i32 2 // CHECK: [[OVERFLOW_AREA:%.+]] = load ptr, ptr [[OVERFLOW_AREA_P]] // Ptr Mask Operations -// CHECK: [[OVERFLOW_AREA_OFFSET_ALIGNED:%.+]] = getelementptr i8, ptr [[OVERFLOW_AREA]], i64 15 +// CHECK: [[OVERFLOW_AREA_OFFSET_ALIGNED:%.+]] = getelementptr inbounds i8, ptr [[OVERFLOW_AREA]], i64 15 // CHECK: [[OVERFLOW_AREA_OFFSET_ALIGNED_P:%.+]] = ptrtoint ptr [[OVERFLOW_AREA_OFFSET_ALIGNED]] to i32 // CHECK: [[MASKED:%.+]] = and i32 [[OVERFLOW_AREA_OFFSET_ALIGNED_P]], -16 // CHECK: [[DIFF:%.+]] = sub i32 [[OVERFLOW_AREA_OFFSET_ALIGNED_P]], [[MASKED]] -// CHECK: [[PTR_MASKED:%.+]] = getelementptr i8, ptr [[OVERFLOW_AREA_OFFSET_ALIGNED]], i32 [[DIFF]] -// CHECK: [[OVERFLOW_AREA_NEXT:%.+]] = getelementptr i8, ptr [[PTR_MASKED]], i64 16 +// CHECK: [[PTR_MASKED:%.+]] = getelementptr inbounds i8, ptr [[OVERFLOW_AREA_OFFSET_ALIGNED]], i32 [[DIFF]] +// CHECK: [[OVERFLOW_AREA_NEXT:%.+]] = getelementptr inbounds i8, ptr [[PTR_MASKED]], i64 16 // CHECK: store ptr [[OVERFLOW_AREA_NEXT]], ptr [[OVERFLOW_AREA_P]] // CHECK: [[VALUE:%.+]] = load x86_fp80, ptr [[PTR_MASKED]] // CHECK: store x86_fp80 [[VALUE]], ptr [[RES]] -// CHECK: [[VA_LIST2:%.+]] = getelementptr {{.*}} [[VA_LIST_ALLOCA]], i32 0 +// CHECK: [[VA_LIST2:%.+]] = getelementptr inbounds {{.*}} [[VA_LIST_ALLOCA]], i32 0 // CHECK: call {{.*}}@llvm.va_end.p0(ptr [[VA_LIST2]]) // CHECK: [[VALUE2:%.+]] = load x86_fp80, ptr [[RES]] // CHECK: store x86_fp80 [[VALUE2]], ptr [[RESULT]]