https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/218375

We call this a lot. Optimize this by inlining and then simplifying the callers, 
i.e. don't call getFieldDesc() as much.

Also remove some code duplication from the similar `Pointer::isOnePastEnd()`.

>From af48f2abe8b1804dbf6b28852814c262cc339a47 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Sun, 23 Aug 2026 07:15:27 +0200
Subject: [PATCH] isonepastend

---
 clang/lib/AST/ByteCode/Pointer.h | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Pointer.h b/clang/lib/AST/ByteCode/Pointer.h
index 78768929f3487..643dfae5cfda9 100644
--- a/clang/lib/AST/ByteCode/Pointer.h
+++ b/clang/lib/AST/ByteCode/Pointer.h
@@ -189,9 +189,21 @@ struct PtrView {
     if (!Pointee)
       return false;
 
-    if (isUnknownSizeArray())
+    if (isPastEnd())
+      return true;
+
+    const Descriptor *Desc = getFieldDesc();
+    if (Desc->isUnknownSizeArray())
       return false;
-    return isPastEnd() || (getSize() == getOffset());
+
+    if (Offset != Base) {
+      unsigned Adjust =
+          Desc->ElemDesc ? sizeof(InlineDescriptor) : sizeof(InitMapPtr);
+      unsigned Off = Offset - Base - Adjust;
+      return Desc->getSize() == Off;
+    }
+
+    return false;
   }
 
   PtrView atIndex(unsigned Idx) const {
@@ -834,10 +846,7 @@ class Pointer {
     if (!BS.Pointee)
       return false;
 
-    if (isUnknownSizeArray())
-      return false;
-
-    return isPastEnd() || (getSize() == getOffset());
+    return view().isOnePastEnd();
   }
 
   /// Checks if the pointer points past the end of the object.

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to