[llvm] [llubi] Global variables with simple initializers and global-address constants (PR #200547)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 1 02:10:26 PDT 2026


================
@@ -41,19 +41,51 @@ bool Context::initGlobalValues() {
       if (!BB.hasAddressTaken())
         continue;
       auto BlockObj = allocate(0, 1, BB.getName(), DL.getProgramAddressSpace(),
-                               MemInitKind::Zeroed, MemAllocKind::Global);
+                               MemInitKind::Zeroed, MemAllocKind::BlockAddress);
       if (!BlockObj)
         return false;
       ValidBlockTargets.try_emplace(BlockObj->getAddress(),
                                     std::make_pair(&BB, BlockObj));
       BlockAddrMap.try_emplace(&BB, deriveFromMemoryObject(BlockObj));
     }
   }
-  // TODO: initialize global variables.
+
+  for (GlobalVariable &GV : M.globals()) {
+    Type *ValueTy = GV.getValueType();
+    uint64_t const Size = getEffectiveTypeAllocSize(ValueTy);
----------------
antoniofrighetto wrote:

Nit:
```suggestion
    const uint64_t Size = getEffectiveTypeAllocSize(ValueTy);
```

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


More information about the llvm-commits mailing list