@@ -454,6 +454,19 @@ class AllocateStmtHelper {
454
454
alloc.getSymbol ());
455
455
}
456
456
457
+ void setPinnedToFalse () {
458
+ if (!pinnedExpr)
459
+ return ;
460
+ Fortran::lower::StatementContext stmtCtx;
461
+ mlir::Value pinned =
462
+ fir::getBase (converter.genExprAddr (loc, *pinnedExpr, stmtCtx));
463
+ mlir::Location loc = pinned.getLoc ();
464
+ mlir::Value falseValue = builder.createBool (loc, false );
465
+ mlir::Value falseConv = builder.createConvert (
466
+ loc, fir::unwrapRefType (pinned.getType ()), falseValue);
467
+ builder.create <fir::StoreOp>(loc, falseConv, pinned);
468
+ }
469
+
457
470
void genSimpleAllocation (const Allocation &alloc,
458
471
const fir::MutableBoxValue &box) {
459
472
bool isCudaSymbol = Fortran::semantics::HasCUDAAttr (alloc.getSymbol ());
@@ -469,6 +482,7 @@ class AllocateStmtHelper {
469
482
// can be validated.
470
483
genInlinedAllocation (alloc, box);
471
484
postAllocationAction (alloc);
485
+ setPinnedToFalse ();
472
486
return ;
473
487
}
474
488
@@ -482,11 +496,13 @@ class AllocateStmtHelper {
482
496
genSetDeferredLengthParameters (alloc, box);
483
497
genAllocateObjectBounds (alloc, box);
484
498
mlir::Value stat;
485
- if (!isCudaSymbol)
499
+ if (!isCudaSymbol) {
486
500
stat = genRuntimeAllocate (builder, loc, box, errorManager);
487
- else
501
+ setPinnedToFalse ();
502
+ } else {
488
503
stat =
489
504
genCudaAllocate (builder, loc, box, errorManager, alloc.getSymbol ());
505
+ }
490
506
fir::factory::syncMutableBoxFromIRBox (builder, loc, box);
491
507
postAllocationAction (alloc);
492
508
errorManager.assignStat (builder, loc, stat);
@@ -616,13 +632,16 @@ class AllocateStmtHelper {
616
632
genSetDeferredLengthParameters (alloc, box);
617
633
genAllocateObjectBounds (alloc, box);
618
634
mlir::Value stat;
619
- if (Fortran::semantics::HasCUDAAttr (alloc.getSymbol ()))
635
+ if (Fortran::semantics::HasCUDAAttr (alloc.getSymbol ())) {
620
636
stat =
621
637
genCudaAllocate (builder, loc, box, errorManager, alloc.getSymbol ());
622
- else if (isSource)
623
- stat = genRuntimeAllocateSource (builder, loc, box, exv, errorManager);
624
- else
625
- stat = genRuntimeAllocate (builder, loc, box, errorManager);
638
+ } else {
639
+ if (isSource)
640
+ stat = genRuntimeAllocateSource (builder, loc, box, exv, errorManager);
641
+ else
642
+ stat = genRuntimeAllocate (builder, loc, box, errorManager);
643
+ setPinnedToFalse ();
644
+ }
626
645
fir::factory::syncMutableBoxFromIRBox (builder, loc, box);
627
646
postAllocationAction (alloc);
628
647
errorManager.assignStat (builder, loc, stat);
0 commit comments