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

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 21:54:50 PDT 2026


================
@@ -166,19 +169,35 @@ static bool InsertRootInitializers(Function &F, ArrayRef<AllocaInst *> Roots) {
 
   // Search for initializers in the initial BB.
   SmallPtrSet<AllocaInst *, 16> InitedRoots;
-  for (; !CouldBecomeSafePoint(&*IP); ++IP)
+  for (; !CouldBecomeSafePoint(&*IP); ++IP) {
+    Value *Dest = nullptr;
     if (StoreInst *SI = dyn_cast<StoreInst>(IP))
-      if (AllocaInst *AI =
-              dyn_cast<AllocaInst>(SI->getOperand(1)->stripPointerCasts()))
+      Dest = SI->getOperand(1);
+    else if (MemSetInst *MSI = dyn_cast<MemSetInst>(IP))
+      Dest = MSI->getDest();
+    if (Dest)
+      if (AllocaInst *AI = dyn_cast<AllocaInst>(Dest->stripPointerCasts()))
         InitedRoots.insert(AI);
+  }
 
-  // Add root initializers.
+  // Add root initializers.  The contents of a root are an opaque blob which
----------------
isuckatcs wrote:

```suggestion
  // Add root initializers. The contents of a root are an opaque blob which
```

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


More information about the llvm-commits mailing list