Skip to content

Conversation

@nikic
Copy link
Contributor

@nikic nikic commented Sep 1, 2025

LangRef currently only says that this determines the return value if the object size if unknown. What it actually does is determine whether the minimum or maximum size is reported, which degenerates to 0 or -1 if unknown.

Fixes #156192.

LangRef currently only says that this determines the return value if
the object size if unknown. What it actually does is determine
whether the minimum or maximum size is reported, which degenerates
to 0 or -1 if unknown.
@llvmbot
Copy link
Member

llvmbot commented Sep 1, 2025

@llvm/pr-subscribers-llvm-ir

Author: Nikita Popov (nikic)

Changes

LangRef currently only says that this determines the return value if the object size if unknown. What it actually does is determine whether the minimum or maximum size is reported, which degenerates to 0 or -1 if unknown.

Fixes #156192.


Full diff: https://github.com/llvm/llvm-project/pull/156309.diff

1 Files Affected:

  • (modified) llvm/docs/LangRef.rst (+9-3)
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index b122fd352eaf5..941a7bea6cffe 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -29557,9 +29557,15 @@ Arguments:
 """"""""""
 
 The ``llvm.objectsize`` intrinsic takes four arguments. The first argument is a
-pointer to or into the ``object``. The second argument determines whether
-``llvm.objectsize`` returns 0 (if true) or -1 (if false) when the object size is
-unknown. The third argument controls how ``llvm.objectsize`` acts when ``null``
+pointer to or into the ``object``.
+
+The second argument determines whether ``llvm.objectsize`` returns the minimum
+(if true) or maximum (if false) object size. The minimum size may be any size
+smaller than or equal to the actual object size (including 0 if unknown). The
+maximum size may be any size greater than or equal to the actual object size
+(including -1 if unknown).
+
+The third argument controls how ``llvm.objectsize`` acts when ``null``
 in address space 0 is used as its pointer argument. If it's ``false``,
 ``llvm.objectsize`` reports 0 bytes available when given ``null``. Otherwise, if
 the ``null`` is in a non-zero address space or if ``true`` is given for the

Copy link
Member

@nunoplopes nunoplopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@nikic nikic merged commit 5256924 into llvm:main Sep 3, 2025
12 checks passed
@nikic nikic deleted the langref-objectsize branch September 3, 2025 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mismatch between @llvm.objectsize and __builtin_object_size semantics

4 participants