-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[IR] Provide well-formed intermediate in ApplyPassToFunction #16843
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
[IR] Provide well-formed intermediate in ApplyPassToFunction #16843
Conversation
|
A follow-up commit to #16801 |
|
Are the substituted global vars restored afterwards? I couldn't find a place where they were put back. I would be worried about these extern funcs ending up in the final module. |
|
The |
|
Wait, a global var can be mapped to an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had no idea that it was possible to have an ExternFunc as a module entry. If this is behavior used elsewhere, I should probably mention this in the specification. Otherwise, this "should" be safe because most accesses of global vars have to check if the value is a Relax Function since it could be a PrimFunc... then again, there might be hazards if a pass assumes (reasonable) that those are the only two possibilities. In any case, this is an improvement compared to passing a potentially malformed module altogether.
|
Yup, But the main impetus for that would have been the |
Prior to this commit, `ApplyPassToFunction` removed functions from the `IRModule` to hide them from the inner `ir.transform.Pass`. The dangling `GlobalVar` references to those functions meant that the intermediate `IRModule` was ill-formed This commit updates the `ApplyPassToFunction` utility to instead replace the functions with `ExternFunc` nodes. This still prevents the inner `ir.transform.Pass` from having visibility into functions that should not be mutated, but provides a well-formed `IRModule`.
ea7ad63 to
5ce7957
Compare
|
Rebased this PR onto main, since #16844 has now landed. |
Prior to this commit,
ApplyPassToFunctionremoved functions from theIRModuleto hide them from the innerir.transform.Pass. The danglingGlobalVarreferences to those functions meant that the intermediateIRModulewas ill-formed This commit updates theApplyPassToFunctionutility to instead replace the functions withExternFuncnodes. This still prevents the innerir.transform.Passfrom having visibility into functions that should not be mutated, but provides a well-formedIRModule.