slyubomirsky commented on PR #16801:
URL: https://github.com/apache/tvm/pull/16801#issuecomment-2030958916

   Hmmm. This approach seems fine for the specific case of DCE, but I wonder if 
the design of `ApplyPassToFunction` needs further thought, since the fact that 
it can output malformed modules could be an issue for other passes as well. 
Maybe the pass infrastructure/interfaces could try to accommodate the case of 
not processing the entire module? A shorter-term change might be ensuring that 
all module-level passes check whether a function is defined when looking up 
global vars (we could make it a helper function in the `ExprMutator` base, 
even, since the examples I found were using the `ExprMutator`'s `mod_` field 
for this purpose). Cursory search for other examples of directly calling 
`Lookup` on `mod_`: `BindSymbolicVars`, `FuseTIR`, `RewriteCudaGraph`, 
`MergeCompositeFunctions`, `LambdaLift`, `DetectRecursion` (analysis), with a 
few others that are related to training or autotuning.
   
   We should be careful about introducing another possible pitfall to pass 
design (in this case having to accommodate a violated invariant).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to