Skip to content

Commit 9c7e362

Browse files
committed
GEP with a constant offset should have inbounds attribute.
Revert "GEP with a constant offset should have inbounds attribute." This reverts commit 5415cbc. [CIR][LowerToLLVM] fixup! GEP with a constant offset should have inbounds attribute
1 parent 888f00c commit 9c7e362

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,9 @@ mlir::LogicalResult CIRToLLVMPtrStrideOpLowering::matchAndRewrite(
851851
}
852852
}
853853

854-
rewriter.replaceOpWithNewOp<mlir::LLVM::GEPOp>(
855-
ptrStrideOp, resultTy, elementTy, adaptor.getBase(), index);
854+
rewriter.replaceOpWithNewOp<mlir::LLVM::GEPOp>(ptrStrideOp, resultTy,
855+
elementTy, adaptor.getBase(),
856+
index, /*inbounds*/ true);
856857
return mlir::success();
857858
}
858859

clang/test/CIR/CodeGen/inbouds.c

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-llvm %s -o %t.ll
2+
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
3+
4+
void foo(int *iptr) { iptr + 2; }
5+
6+
// LLVM: getelementptr inbounds i32,

0 commit comments

Comments
 (0)