Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754113AbbHFEgB (ORCPT ); Thu, 6 Aug 2015 00:36:01 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:30776 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751377AbbHFEgA (ORCPT ); Thu, 6 Aug 2015 00:36:00 -0400 Message-ID: <55C2E412.70503@huawei.com> Date: Thu, 6 Aug 2015 12:35:30 +0800 From: "Wangnan (F)" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Alexei Starovoitov CC: Alexei Starovoitov , He Kuang , pi3orama , , "linux-kernel@vger.kernel.org" Subject: Re: [llvm-dev] [LLVMdev] Cc llvmdev: Re: llvm bpf debug info. Re: [RFC PATCH v4 3/3] bpf: Introduce function for outputing data to perf event References: <55B89F04.5030304@huawei.com> <55B909B2.2080606@plumgrid.com> <55BB4B8A.5000207@huawei.com> <55BFC4A0.9060100@plumgrid.com> <55C07F5B.6030107@huawei.com> <55C16DC7.70408@huawei.com> <55C16F53.3070604@huawei.com> <55C1B254.5030801@huawei.com> <55C1B717.60501@plumgrid.com> <55C1C91D.5080007@huawei.com> <20150806032221.GA52057@Alexeis-MBP.westell.com> In-Reply-To: <20150806032221.GA52057@Alexeis-MBP.westell.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.66.109] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2699 Lines: 93 On 2015/8/6 11:22, Alexei Starovoitov wrote: > On Wed, Aug 05, 2015 at 04:28:13PM +0800, Wangnan (F) wrote: >> It doesn't work for me at first since in my llvm there's only >> llvm.bpf.load.*. >> >> I think llvm.bpf.store.* belone to some patches you haven't posted yet? > nope. only loads have special instructions ld_abs/ld_ind > which are represented by these intrinsics. > stores, so far, are done via single bpf_store_bytes() helper function. > >>> the typeid changing ids with order is surprising. >>> I think the assertion in ExtractTypeInfo() is not hard. >>> Just there were no such use cases. May be we can do something >>> similar to what LowerIntrinsicCall() does and lower it differently >>> in the backend. >>> >> But in backend can we still get type information? I thought type is >> meaningful in frontend only, and backend behaviors is unable to affect >> DWARF generation, right? > why do we need to affect type generation? we just need to know dwarf > type id in the backend, so we can emit it as a constant. > I still think lowering eh_typeid_for differently may work. > Like instead of doing > GV = ExtractTypeInfo(I.getArgOperand(0)) followed by > getMachineFunction().getMMI().getTypeIDFor(GV) > we can get dwarf type id from I.getArgOperand(0) if it's > any pointer to struct type. I have a bad news to tell: #include struct my_str { int x; int y; } __gv_my_str; struct my_str __gv_my_str_; struct my_str2 { int x; int y; } __gv_my_str2; int typeid(void *p) asm("llvm.eh.typeid.for"); int main() { printf("%d\n", typeid(&__gv_my_str)); printf("%d\n", typeid(&__gv_my_str_)); printf("%d\n", typeid(&__gv_my_str2)); return 0; } Compiled with clang into x86 executable, then: $ ./a.out 3 2 1 See? I have two types but reported 3 IDs. And here is the implementation of getTypeIDFor, in lib/CodeGen/MachineModuleInfo.cpp: unsigned MachineModuleInfo::getTypeIDFor(const GlobalValue *TI) { for (unsigned i = 0, N = TypeInfos.size(); i != N; ++i) if (TypeInfos[i] == TI) return i + 1; TypeInfos.push_back(TI); return TypeInfos.size(); } It only checks value in a stupid way. Now the dwarf side becomes clear (see my other response), but the frontend may require totally reconsidering. Do you know someone in LLVM-dev who can help us? Thank you. > I'm not familiar with dwarf handling part of llvm, but feels possible. > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/