Skip to content

[flang] fix procedure fir.box_addr identification in boxed-procedure #79290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ class BoxedProcedurePass
if (auto addr = mlir::dyn_cast<BoxAddrOp>(op)) {
mlir::Type ty = addr.getVal().getType();
mlir::Type resTy = addr.getResult().getType();
if (typeConverter.needsConversion(ty) ||
ty.isa<mlir::FunctionType>()) {
if (llvm::isa<mlir::FunctionType>(ty) ||
llvm::isa<fir::BoxProcType>(ty)) {
// Rewrite all `fir.box_addr` ops on values of type `!fir.boxproc`
// or function type to be `fir.convert` ops.
rewriter.setInsertionPoint(addr);
Expand Down
8 changes: 8 additions & 0 deletions flang/test/Fir/boxproc-2.fir
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,11 @@ func.func @block_arg_rewrite(%arg0: !fir.ref<!fir.type<t{p:!fir.boxproc<() -> ()
// CHECK: fir.call @dosomething(%[[VAL_3]]) : (!fir.ref<!fir.type<tUnboxProc{p:() -> ()}>>) -> ()

func.func private @dosomething(!fir.ref<!fir.type<t{p:!fir.boxproc<() -> ()>}>>)

!t2 = !fir.type<t2{i:!fir.boxproc<() -> ()>}>
func.func @box_addr_test(%arg0: !fir.box<!t2>) -> !fir.ref<!t2> {
%3 = fir.box_addr %arg0 : (!fir.box<!t2>) -> !fir.ref<!t2>
return %3 : !fir.ref<!t2>
}
// CHECK: func.func @box_addr_test(
// CHECK: fir.box_addr %{{.*}} : (!fir.box<!fir.type<t2UnboxProc{i:() -> ()}>>) -> !fir.ref<!fir.type<t2UnboxProc{i:() -> ()}>>