[llvm] [IR][CodeGen] Specify llvm.gcroot contents are an opaque zero-initialized blob (PR #222333)

Jameson Nash via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 07:51:20 PDT 2026


================
@@ -14433,17 +14433,26 @@ the code generator, and allows some metadata to be associated with it.
 
 ##### Arguments:
 
-The first argument specifies the address of a stack object that contains
-the root pointer. The second pointer (which must be either a constant or
-a global value address) contains the meta-data to be associated with the
-root.
-
-##### Semantics:
-
-At runtime, a call to this intrinsic stores a null pointer into the
-"ptrloc" location. At compile-time, the code generator generates
-information to allow the runtime to find the pointer at GC safe points.
-The '`llvm.gcroot`' intrinsic may only be used in a function which
+The first argument specifies the address of a stack object holding the
+root, which must be a static `alloca`. LLVM attaches no meaning to the
+contents of that object: it is an opaque blob of arbitrary type which
+the runtime garbage collector may interpret in any way it likes. In
+particular it need not be, or contain, a pointer. The second pointer
+(which must be either a constant or a global value address) contains the
+meta-data to be associated with the root.
+
+##### Semantics:
+
+The frontend is responsible for initializing the "ptrloc" object before
+the first GC safe point is reached, since the collector may inspect it
+there. What it stores is up to the collector's conventions and need not
----------------
vtjnash wrote:

That seems different though, since you're showing an ICE, not a miscompile, and also showing that it doesn't zero it out (the memset, which seems to be a correct optimization of the original store, and stays after the zero store).

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


More information about the llvm-commits mailing list