[llvm] BasicAA: update comments in a routine (NFC) (PR #110492)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 30 06:53:55 PDT 2024


================
@@ -134,20 +134,13 @@ static bool isObjectSmallerThan(const Value *V, TypeSize Size,
   //     char *p = (char*)malloc(100)
   //     char *q = p+80;
   //
-  //  In the context of c1 and c2, the "object" pointed by q refers to the
+  // In the context of c1 and c2, the "object" pointed by q refers to the
   // stretch of memory of q[0:19]. So, getObjectSize(q) should return 20.
   //
-  //  However, in the context of c3, the "object" refers to the chunk of memory
-  // being allocated. So, the "object" has 100 bytes, and q points to the middle
-  // the "object". In case q is passed to isObjectSmallerThan() as the 1st
-  // parameter, before the llvm::getObjectSize() is called to get the size of
-  // entire object, we should:
-  //    - either rewind the pointer q to the base-address of the object in
-  //      question (in this case rewind to p), or
-  //    - just give up. It is up to caller to make sure the pointer is pointing
-  //      to the base address the object.
-  //
-  // We go for 2nd option for simplicity.
+  // In the context of c3, the "object" refers to the chunk of memory being
+  // allocated. So, the "object" has 100 bytes, and q points to the middle the
+  // "object". However, getUnderlyingObject() is first called on q to get p, and
+  // p is passed to isObjectSmallerThan() as the 1st parameter.
----------------
nikic wrote:

I feel like the more pertinent observation here is that the isIdentifiedObject call below ensures that we have a pointer to the start of the object (at least for the cases where an object size can be determined). Calling getUnderlyingObject() by itself does not mean that you get the root object.

https://github.com/llvm/llvm-project/pull/110492


More information about the llvm-commits mailing list