How to automatically change funcOp's type?

Hi all,

I came across a problem that I change the return Op in pattern rewriter, if I do nothing, it will of course issue an error since funcOp’s type not changed. However, I cannot obtain the funcOp in rewriter instead of a pass.

So my question is how to automatically trigger the funcOp to self-change the type, is there a mechanism? Or how can I obtain the funcOp pointer in the rewriter?

Thanks in advance!

You can try using:

returnOp->getParentOfType<func::FuncOp>()

to obtain the funcOp pointer.

@maya_amrami Thank you, maya! I will try your method.

Blockquote