Skip to content

Commit

Permalink
GEP with a constant offset should have inbounds attribute.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
liusy58 committed Dec 3, 2024
1 parent 888f00c commit 9c7e362
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,9 @@ mlir::LogicalResult CIRToLLVMPtrStrideOpLowering::matchAndRewrite(
}
}

rewriter.replaceOpWithNewOp<mlir::LLVM::GEPOp>(
ptrStrideOp, resultTy, elementTy, adaptor.getBase(), index);
rewriter.replaceOpWithNewOp<mlir::LLVM::GEPOp>(ptrStrideOp, resultTy,
elementTy, adaptor.getBase(),
index, /*inbounds*/ true);
return mlir::success();
}

Expand Down
6 changes: 6 additions & 0 deletions clang/test/CIR/CodeGen/inbouds.c
Original file line number Diff line number Diff line change
@@ -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 i32,

0 comments on commit 9c7e362

Please sign in to comment.