[llvm] BasicAA: update comments in a routine (NFC) (PR #110492)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 30 04:22:41 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Ramkumar Ramachandra (artagnon)
<details>
<summary>Changes</summary>
The comments in isObjectSmallerThan are outdated, as it is only ever called with the underlying object as the first argument. Update the comments to reflect this.
---
Full diff: https://github.com/llvm/llvm-project/pull/110492.diff
1 Files Affected:
- (modified) llvm/lib/Analysis/BasicAliasAnalysis.cpp (+6-13)
``````````diff
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index a00ed7530ebc4c..1c94ccd66436d8 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -117,7 +117,7 @@ static std::optional<TypeSize> getObjectSize(const Value *V,
}
/// Returns true if we can prove that the object specified by V is smaller than
-/// Size.
+/// Size. The underlying object is expected to be passed as the first argument.
static bool isObjectSmallerThan(const Value *V, TypeSize Size,
const DataLayout &DL,
const TargetLibraryInfo &TLI,
@@ -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.
if (!isIdentifiedObject(V))
return false;
``````````
</details>
https://github.com/llvm/llvm-project/pull/110492
More information about the llvm-commits
mailing list