File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -453,12 +453,28 @@ namespace vast
453
453
{
454
454
auto loc = indirect.getLoc ();
455
455
auto mctx = indirect.getContext ();
456
- auto type = hl::PointerType::get (mctx, indirect.getValue (). getType () );
457
-
456
+ auto indirect_val = indirect.getValue ();
457
+ auto type = hl::PointerType::get (mctx, indirect_val. getType ());
458
458
auto var = state.rewriter .template create < ll::Alloca >(
459
459
indirect.getLoc (), type);
460
+
460
461
// Now we initilizae before yielding the ptr
461
- state.rewriter .template create < ll::Store >(loc, indirect.getValue (), var);
462
+ if (auto load = mlir::dyn_cast< ll::Load >(indirect_val.getDefiningOp ())) {
463
+ size_t bits = dl.getTypeSizeInBits (indirect_val.getType ());
464
+ size_t bytes = dl.getTypeSize (indirect_val.getType ());
465
+ state.rewriter .template create < ll::MemcpyOp >(
466
+ loc,
467
+ load.getPtr (),
468
+ var,
469
+ mlir::IntegerAttr::get (mlir::IntegerType::get (mctx, bytes), bits),
470
+ // FIXME:
471
+ mlir::BoolAttr::get (mctx, false ) /* isVolatile*/
472
+ );
473
+ state.rewriter .eraseOp (load);
474
+
475
+ } else {
476
+ state.rewriter .template create < ll::Store >(loc, indirect_val, var);
477
+ }
462
478
co_yield var;
463
479
}
464
480
};
You can’t perform that action at this time.
0 commit comments