File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -1199,6 +1199,9 @@ ValueCategory MLIRScanner::VisitCXXNewExpr(clang::CXXNewExpr *expr) {
1199
1199
auto shape = std::vector<int64_t >(mt.getShape ());
1200
1200
mlir::Value args[1 ] = {count};
1201
1201
arrayCons = alloc = builder.create <mlir::memref::AllocOp>(loc, mt, args);
1202
+ if (expr->hasInitializer () && isa<InitListExpr>(expr->getInitializer ()))
1203
+ (void )InitializeValueByInitListExpr (alloc, expr->getInitializer ());
1204
+
1202
1205
} else {
1203
1206
auto i64 = mlir::IntegerType::get (count.getContext (), 64 );
1204
1207
auto typeSize = getTypeSize (expr->getAllocatedType ());
Original file line number Diff line number Diff line change
1
+ // RUN: cgeist %s %stdinclude --function=* -S | FileCheck %s
2
+
3
+ #include < stdio.h>
4
+
5
+ struct A {
6
+ float x, y;
7
+ };
8
+
9
+ void f (A *a) { printf (" a.x = %f, a.y = %f\n " , a->x , a->y ); }
10
+
11
+ int main (int argc, char const *argv[]) {
12
+ // CHECK-DAG: %[[two:.*]] = arith.constant 2.000000e+00 : f32
13
+ // CHECK-DAG: %[[one:.*]] = arith.constant 1.000000e+00 : f32
14
+ // CHECK: %[[alloc:.*]] = memref.alloc() : memref<1x2xf32>
15
+ // CHECK: affine.store %[[one]], %[[alloc]][0, 0] : memref<1x2xf32>
16
+ // CHECK: affine.store %[[two]], %[[alloc]][0, 1] : memref<1x2xf32>
17
+ auto *a = new A{1 .0f , 2 .0f };
18
+ f (a);
19
+ return 0 ;
20
+ }
You can’t perform that action at this time.
0 commit comments