This is an archive of the discontinued LLVM Phabricator instance.

[flang] Support codegen for global procedure pointer
ClosedPublic

Authored by peixin on Nov 18 2022, 2:07 AM.

Details

Summary

This supports the codegen for global procedure pointer in BoxedProcedure
pass. Reset the boxproc type.

Depends on D136842.

Diff Detail

Event Timeline

peixin created this revision.Nov 18 2022, 2:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 18 2022, 2:07 AM
peixin requested review of this revision.Nov 18 2022, 2:07 AM

I think you may need to use updateRootInPlace, otherwise LGTM

flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp
259

I will let @clementval or someone else familiar will MLIR patterns, but I think that if you update an operation in place, you need to use rewriter.updateRootInPlace (or startRootUpdate/finalizeRootUpdate).

clementval added inline comments.Nov 18 2022, 11:31 AM
flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp
259

@jeanPerier is right. If you don't want weird behavior it is better to use the rewriter to perform the in place update so it is recorded and propagated accordingly.

peixin updated this revision to Diff 476646.Nov 18 2022, 6:58 PM

Thanks @jeanPerier and @clementval . You are right. As mlir/docs/PatternRewriter.md, matchAndRewrite has the restriction of "the root operation is required to either be: updated in-place, replaced, or erased.", and an operation is updated in-place using the transaction-like API (start|cancel|finalize)RootUpdate. Fixed.

jeanPerier accepted this revision.Nov 21 2022, 12:37 AM

Thanks, LGTM

This revision is now accepted and ready to land.Nov 21 2022, 12:37 AM
This revision was automatically updated to reflect the committed changes.