altanh commented on pull request #10026:
URL: https://github.com/apache/tvm/pull/10026#issuecomment-1027242901


   I wrote this as a comment in the code, but reposting here for future 
reference:
   ```
   Current Limitations
   -------------------
   1. For simplicity, we only insert kills when visiting Let bindings, and 
always emit the kill as a
   single subsequent binding. This is slightly inaccurate; for example, if the 
condition of an If
   is dead after the test, we can immediately kill the condition in each branch:
     let %x = if (%dead_cond) {
       let %_0 = memory.kill(%dead_cond);
       ...
     } else {
       let %_1 = memory.kill(%dead_cond);
       ...
     }
   as opposed to:
     let %x = if (%dead_cond) ...
     let %_0 = memory.kill(%dead_cond);
   
   2. Killed variables are calculated as live in - live out, which misses 
variables that are
   actually dead but not in live in. Examples include: when the last use of a 
var is the result
   expr of an If branch; when bound vars (i.e. function inputs, pattern matched 
vars, dead 
   bindings) are never used.
   
   3. When the result expr of an If branch is a variable, and this expr is the 
last use of the
   var, we cannot "kill" the var since it is being returned. The VM compiler 
also emits a Move
   instruction to merge the branch results, which creates another ObjectRef to 
the Object held
   by the var. The var is also not in the subsequent live-in (since it is 
indeed dead by this
   point, see above), so it won't be killed.
   
   However, these limitations are unlikely to cause large leaks in practice.
   ```


-- 
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