[Mlir-commits] [mlir] Expand the MemRefToEmitC pass - Adding scalars (PR #148055)

Simon Camphausen llvmlistbot at llvm.org
Mon Jul 14 10:21:12 PDT 2025


================
@@ -132,7 +144,17 @@ struct ConvertGetGlobal final
   matchAndRewrite(memref::GetGlobalOp op, OpAdaptor operands,
                   ConversionPatternRewriter &rewriter) const override {
 
-    auto resultTy = getTypeConverter()->convertType(op.getType());
+    MemRefType type = op.getType();
+    Type resultTy;
+    if (type.getRank() == 0)
+      resultTy = emitc::LValueType::get(
----------------
simon-camp wrote:

Note that in general lowering getglobal to lvalue doesn't work correctly when the result is passed to function calls for example. So I would expect rank 0 memrefs to be lowered to pointers (at least when it might escape).

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


More information about the Mlir-commits mailing list