[llvm] [IR] Update docstring for stripAndAccumulateConstantOffset (PR #180365)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 9 06:28:27 PST 2026


https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/180365

>From 192338498badad96757dc0479d02bd5fe792f807 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Sat, 7 Feb 2026 19:15:13 +0000
Subject: [PATCH 1/3] [IR] Update docstring for
 stripAndAccumulateConstantOffset

Make it clear that the returned object in the case where a variable
offset is found is the first value to introduce a non-constant offset,
not necessarily the actual underlying object.

Found while investigating #180361.
---
 llvm/include/llvm/IR/Value.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/IR/Value.h b/llvm/include/llvm/IR/Value.h
index 4a15251f0b945..b761e10dfa667 100644
--- a/llvm/include/llvm/IR/Value.h
+++ b/llvm/include/llvm/IR/Value.h
@@ -733,8 +733,8 @@ class Value {
   /// Note that this function will never return a nullptr. It will also never
   /// manipulate the \p Offset in a way that would not match the difference
   /// between the underlying value and the returned one. Thus, if no constant
-  /// offset was found, the returned value is the underlying one and \p Offset
-  /// is unchanged.
+  /// offset was found, \p Offset is unchanged and the returned value is the
+  /// first traversed value to introduce a non-constant offset.
   LLVM_ABI const Value *stripAndAccumulateConstantOffsets(
       const DataLayout &DL, APInt &Offset, bool AllowNonInbounds,
       bool AllowInvariantGroup = false,

>From 5b085597d0d97c3bc5c6a7e34c6fbd8df1e2c020 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Sat, 7 Feb 2026 19:30:48 +0000
Subject: [PATCH 2/3] feedback

---
 llvm/include/llvm/IR/Value.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/IR/Value.h b/llvm/include/llvm/IR/Value.h
index b761e10dfa667..b088e8c398578 100644
--- a/llvm/include/llvm/IR/Value.h
+++ b/llvm/include/llvm/IR/Value.h
@@ -732,9 +732,10 @@ class Value {
   ///
   /// Note that this function will never return a nullptr. It will also never
   /// manipulate the \p Offset in a way that would not match the difference
-  /// between the underlying value and the returned one. Thus, if no constant
-  /// offset was found, \p Offset is unchanged and the returned value is the
-  /// first traversed value to introduce a non-constant offset.
+  /// between the underlying value and the returned one. Thus, if a variable
+  /// offset was encountered, the returned value is the first traversed value
+  /// to introduce a non-constant offset and \p Offset is the accumulated
+  /// constant offset up to that point.
   LLVM_ABI const Value *stripAndAccumulateConstantOffsets(
       const DataLayout &DL, APInt &Offset, bool AllowNonInbounds,
       bool AllowInvariantGroup = false,

>From d1aaa14d987ad4aab86ea117fd24dc6094afaa0b Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Mon, 9 Feb 2026 14:28:12 +0000
Subject: [PATCH 3/3] word smithing

---
 llvm/include/llvm/IR/Value.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/IR/Value.h b/llvm/include/llvm/IR/Value.h
index b088e8c398578..a22c324189b9a 100644
--- a/llvm/include/llvm/IR/Value.h
+++ b/llvm/include/llvm/IR/Value.h
@@ -733,9 +733,9 @@ class Value {
   /// Note that this function will never return a nullptr. It will also never
   /// manipulate the \p Offset in a way that would not match the difference
   /// between the underlying value and the returned one. Thus, if a variable
-  /// offset was encountered, the returned value is the first traversed value
-  /// to introduce a non-constant offset and \p Offset is the accumulated
-  /// constant offset up to that point.
+  /// offset is encountered during traversal, the returned value is the first
+  /// traversed Value that introduces a non-constant offset and \p Offset is the
+  /// accumulated constant offset up to that point.
   LLVM_ABI const Value *stripAndAccumulateConstantOffsets(
       const DataLayout &DL, APInt &Offset, bool AllowNonInbounds,
       bool AllowInvariantGroup = false,



More information about the llvm-commits mailing list