[Mlir-commits] [mlir] [mlir][EmitC]Allow Fields to have initial values (PR #151437)

Jaden Angella llvmlistbot at llvm.org
Thu Jul 31 16:17:53 PDT 2025


================
@@ -39,13 +37,46 @@ emitc.class final @finalClass {
 
 // CHECK-LABEL: class finalClass final {
 // CHECK-NEXT: public:
-// CHECK-NEXT:  float[1] fieldName0;
-// CHECK-NEXT:  float[1] fieldName1;
+// CHECK-NEXT:  float fieldName0[1];
+// CHECK-NEXT:  float fieldName1[1];
 // CHECK-NEXT:  void execute() {
 // CHECK-NEXT:    size_t v1 = 0;
-// CHECK-NEXT:    float[1] v2 = fieldName0;
-// CHECK-NEXT:    float[1] v3 = fieldName1;
 // CHECK-NEXT:    return;
----------------
Jaddyen wrote:

They go away because they aren't initialized. 
The change in this patch ensures that we only emit `get_field` in the case that we initialized the field.
This is in line with how `get_global` works.
Yes to the two last questions!

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


More information about the Mlir-commits mailing list