[Mlir-commits] [mlir] [MLIR][LLVM] Implement LLVM dialect support for global aliases (PR #125295)

Christian Ulmann llvmlistbot at llvm.org
Mon Feb 3 23:55:05 PST 2025


================
@@ -1248,6 +1281,30 @@ LogicalResult ModuleTranslation::convertGlobals() {
         llvm::MDTuple::get(getLLVMContext(), globals));
   }
 
+  // Convert global alias bodies.
+  for (auto op : getModuleBody(mlirModule).getOps<LLVM::AliasOp>()) {
+    Block &initializer = op.getInitializerBlock();
+    llvm::IRBuilder<> builder(llvmModule->getContext());
+
+    for (mlir::Operation &op : initializer.without_terminator()) {
+      if (failed(convertOperation(op, builder)))
+        return emitError(op.getLoc(), "fail to convert alias initializer");
+      auto *cst = dyn_cast<llvm::Constant>(lookupValue(op.getResult(0)));
+      if (!cst)
----------------
Dinistro wrote:

Nit: you can use `isa` here, no need to perform the actual cast.

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


More information about the Mlir-commits mailing list