From 0362c644c58f77d5252b72d92381934fb63ab316 Mon Sep 17 00:00:00 2001 From: liusy58 Date: Mon, 2 Dec 2024 11:52:12 +0800 Subject: [PATCH] [CIR][LowerToLLVM] fixup! CIR generated LLVM code for pointer arithmetic should have inbounds. --- .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 5 +++-- .../CIR/CodeGen/address-space-conversion.cpp | 2 +- clang/test/CIR/CodeGen/clear_cache.c | 2 +- clang/test/CIR/CodeGen/initlist-ptr-ptr.cpp | 4 ++-- clang/test/CIR/CodeGen/pointer-arith-ext.c | 16 ++++++++-------- clang/test/CIR/CodeGen/ptr_stride.c | 6 ++++++ clang/test/CIR/CodeGen/var-arg-float.c | 4 ++-- clang/test/CIR/CodeGen/var-arg-scope.c | 4 ++-- clang/test/CIR/CodeGen/var-arg.c | 4 ++-- 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 | 2 +- clang/test/CIR/Lowering/ptrstride.cir | 4 ++-- clang/test/CIR/Lowering/var-arg-x86_64.c | 4 ++-- 15 files changed, 40 insertions(+), 33 deletions(-) create mode 100644 clang/test/CIR/CodeGen/ptr_stride.c diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp index 9b78457da9db..18d9de9ed169 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp @@ -851,8 +851,9 @@ mlir::LogicalResult CIRToLLVMPtrStrideOpLowering::matchAndRewrite( } } - rewriter.replaceOpWithNewOp( - ptrStrideOp, resultTy, elementTy, adaptor.getBase(), index); + rewriter.replaceOpWithNewOp(ptrStrideOp, resultTy, + elementTy, adaptor.getBase(), + index, /*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..aefc28ffd864 100644 --- a/clang/test/CIR/CodeGen/initlist-ptr-ptr.cpp +++ b/clang/test/CIR/CodeGen/initlist-ptr-ptr.cpp @@ -79,11 +79,11 @@ void test() { // LLVM: [[SCOPE_START]]: ; preds = %0 // LLVM: [[PTR_FIRST_ELEM:%.*]] = getelementptr 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: 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: [[ELEM_ARRAY_END:%.*]] = getelementptr inbounds 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: store ptr [[ELEM_ARRAY_END]], ptr [[INIT_END_FLD_PTR]], align 8 // LLVM: [[ARG2PASS:%.*]] = load %"class.std::initializer_list", ptr [[INIT_STRUCT]], align 8 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/ptr_stride.c b/clang/test/CIR/CodeGen/ptr_stride.c new file mode 100644 index 000000000000..3b9e54ff0d7f --- /dev/null +++ b/clang/test/CIR/CodeGen/ptr_stride.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-llvm %s -o %t.ll +// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM + +void foo(int *iptr) { iptr + 2; } + +// LLVM: getelementptr inbounds \ No newline at end of file diff --git a/clang/test/CIR/CodeGen/var-arg-float.c b/clang/test/CIR/CodeGen/var-arg-float.c index 5b8539cfa380..e817ba265669 100644 --- a/clang/test/CIR/CodeGen/var-arg-float.c +++ b/clang/test/CIR/CodeGen/var-arg-float.c @@ -97,13 +97,13 @@ double f1(int n, ...) { // LLVM-NEXT: [[VR_TOP_P:%.*]] = getelementptr %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_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..4cde95e20b00 100644 --- a/clang/test/CIR/CodeGen/var-arg-scope.c +++ b/clang/test/CIR/CodeGen/var-arg-scope.c @@ -86,13 +86,13 @@ void f1(__builtin_va_list c) { // LLVM-NEXT: [[GR_TOP_P:%.*]] = getelementptr %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_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..13cbb7fe2fd6 100644 --- a/clang/test/CIR/CodeGen/var-arg.c +++ b/clang/test/CIR/CodeGen/var-arg.c @@ -100,13 +100,13 @@ int f1(int n, ...) { // LLVM-NEXT: [[GR_TOP_P:%.*]] = getelementptr %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_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..67a51cbe290e 100644 --- a/clang/test/CIR/Lowering/globals.cir +++ b/clang/test/CIR/Lowering/globals.cir @@ -183,7 +183,7 @@ module { //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: %[[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: %[[RES7:.*]] = llvm.getelementptr inbounds %[[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: %[[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..f14bd7a1c8f4 100644 --- a/clang/test/CIR/Lowering/var-arg-x86_64.c +++ b/clang/test/CIR/Lowering/var-arg-x86_64.c @@ -94,12 +94,12 @@ long double f2(int n, ...) { // CHECK: [[OVERFLOW_AREA_P:%.+]] = getelementptr {{.*}} [[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: [[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]]