https://github.com/AtariDreams created https://github.com/llvm/llvm-project/pull/94883
None >From 9db997477f3a5649092b9bf385a6a1d963b4971b Mon Sep 17 00:00:00 2001 From: Rose <gfunni...@gmail.com> Date: Sat, 8 Jun 2024 22:30:53 -0400 Subject: [PATCH] Assume a for-in loop is in bounds and cannot overflow --- clang/lib/CodeGen/CGObjC.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index 281b2d9795f6c..80a64d8e4cdd9 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -1952,7 +1952,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){ Builder.CreateLoad(StateItemsPtr, "stateitems"); // Fetch the value at the current index from the buffer. - llvm::Value *CurrentItemPtr = Builder.CreateGEP( + llvm::Value *CurrentItemPtr = Builder.CreateInBoundsGEP( ObjCIdType, EnumStateItems, index, "currentitem.ptr"); llvm::Value *CurrentItem = Builder.CreateAlignedLoad(ObjCIdType, CurrentItemPtr, getPointerAlign()); @@ -2028,7 +2028,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){ // First we check in the local buffer. llvm::Value *indexPlusOne = - Builder.CreateAdd(index, llvm::ConstantInt::get(NSUIntegerTy, 1)); + Builder.CreateNUWAdd(index, llvm::ConstantInt::get(NSUIntegerTy, 1)); // If we haven't overrun the buffer yet, we can continue. // Set the branch weights based on the simplifying assumption that this is _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits