You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/03/25 14:07:31 UTC

[GitHub] [incubator-tvm] kumasento opened a new pull request #5146: Handle empty LLVMModule in GetFunction

kumasento opened a new pull request #5146: Handle empty LLVMModule in GetFunction
URL: https://github.com/apache/incubator-tvm/pull/5146
 
 
   #4847 introduces empty `LLVMModule`, which may appear when all the executable code are optimized #4748 . An empty `LLVMModule` is built from an IR file that only specifies target triplet and data layout.
   
   We just notice that existing logic in `LLVMModuleNode` may not consider this case properly. As shown by @trevor-m in this [comment](https://github.com/apache/incubator-tvm/pull/4847#issuecomment-600221459), `LLVMModuleNode::GetFunction` doesn't work properly.
   
   We dived into this problem and found out that `LLVMModuleNode` always assumes there exists an entry function (see this [line](https://github.com/apache/incubator-tvm/blob/3aabbd9c30d247a31eb19ebf997d6074b14b5dd9/src/target/llvm/llvm_module.cc#L321-L322)). If there is not, e.g., in an empty `LLVMModule`, we would have trouble, mostly in the form of segfault.
   
   This PR mainly deals with the empty `LLVMModule` issue in `LLVMModuleNode::GetFunction`. We assume that, without losing generality, a `LLVMModule` is empty if its `entry_func_` cannot be found, i.e.:
   
   ```c++
   GetGlobalAddr(runtime::symbol::tvm_module_main) == 0
   ```
   
   We use this assumption as follows:
   
   1. When `LazyInitJIT` is called by `GetFunction`, we will validate the address of `entry_func_` (by the condition above) first before we refer to it. 
   2. If `entry_func_` is empty, we can realize the current `LLVMModule` is empty and we should return `nullptr`.
   
   Please let me know whether this help address your problem @trevor-m 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] trevor-m commented on issue #5146: Handle empty LLVMModule in GetFunction

Posted by GitBox <gi...@apache.org>.
trevor-m commented on issue #5146: Handle empty LLVMModule in GetFunction
URL: https://github.com/apache/incubator-tvm/pull/5146#issuecomment-604059024
 
 
   Thanks @kumasento ! I have confirmed that this fixes my issue with external codegen.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] FrozenGene merged pull request #5146: Handle empty LLVMModule in GetFunction

Posted by GitBox <gi...@apache.org>.
FrozenGene merged pull request #5146: Handle empty LLVMModule in GetFunction
URL: https://github.com/apache/incubator-tvm/pull/5146
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] FrozenGene commented on issue #5146: Handle empty LLVMModule in GetFunction

Posted by GitBox <gi...@apache.org>.
FrozenGene commented on issue #5146: Handle empty LLVMModule in GetFunction
URL: https://github.com/apache/incubator-tvm/pull/5146#issuecomment-604187370
 
 
   Thanks @kumasento for fixing it. Thanks @trevor-m @zhiics for verifying and reviewing. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services