From commits-return-9459-archive-asf-public=cust-asf.ponee.io@tvm.apache.org Wed Mar 25 14:07:32 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 4D94818063D for ; Wed, 25 Mar 2020 15:07:32 +0100 (CET) Received: (qmail 32544 invoked by uid 500); 25 Mar 2020 14:07:31 -0000 Mailing-List: contact commits-help@tvm.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tvm.apache.org Delivered-To: mailing list commits@tvm.apache.org Received: (qmail 32535 invoked by uid 99); 25 Mar 2020 14:07:31 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Mar 2020 14:07:31 +0000 From: GitBox To: commits@tvm.apache.org Subject: [GitHub] [incubator-tvm] kumasento opened a new pull request #5146: Handle empty LLVMModule in GetFunction Message-ID: Date: Wed, 25 Mar 2020 14:07:31 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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