Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751756AbbHEGvT (ORCPT ); Wed, 5 Aug 2015 02:51:19 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:27205 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751218AbbHEGvS (ORCPT ); Wed, 5 Aug 2015 02:51:18 -0400 Message-ID: <55C1B254.5030801@huawei.com> Date: Wed, 5 Aug 2015 14:51:00 +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 , He Kuang , pi3orama CC: , "linux-kernel@vger.kernel.org" Subject: Re: [LLVMdev] Cc llvmdev: Re: llvm bpf debug info. Re: [RFC PATCH v4 3/3] bpf: Introduce function for outputing data to perf event References: <1436522587-136825-1-git-send-email-hekuang@huawei.com> <1436522587-136825-4-git-send-email-hekuang@huawei.com> <55A042DC.6030809@plumgrid.com> <55A3404B.6020904@huawei.com> <20150713135223.GB9917@danjae.kornet> <4D441676-21A7-46EE-AAB0-EB529D408082@163.com> <20150713140915.GD9917@danjae.kornet> <55A46928.9090708@plumgrid.com> <55A4F869.1020705@huawei.com> <55A88085.8090407@plumgrid.com> <55A88137.7020609@huawei.com> <55A88449.3030008@plumgrid.com> <55B0D5FC.6050406@huawei.com> <55B1535E.8090406@plumgrid.com> <55B1AEE9.1080207@plumgrid.com> <55B1BC03.9020708@huawei.com> <55B35F42.70803@huawei.com> <55B6E685.30905@plumgrid.com> <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> In-Reply-To: <55C16F53.3070604@huawei.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: 2746 Lines: 103 On 2015/8/5 10:05, Wangnan (F) wrote: > Send again since llvmdev is moved to llvm-dev@lists.llvm.org > > On 2015/8/5 9:58, Wangnan (F) wrote: >> >>> >>> On 2015/8/4 3:44, Alexei Starovoitov wrote: >>>> On 7/31/15 3:18 AM, Wangnan (F) wrote: >>>> >>> >>> [SNIP] >>> >>>> didn't have time to look at it. >>>> from your llvm patches looks like you've got quite experienced >>>> with it already :) >>>> >>>>> I'll post 2 LLVM patches by replying this mail. Please have a look >>>>> and >>>>> help me >>>>> send them to LLVM if you think my code is correct. >>>> >>>> patch 1: >>>> I don't quite understand the purpose of builtin_dwarf_cfa >>>> returning R11. It's a special register seen inside llvm codegen >>>> only. It doesn't have kernel meaning. >>>> >>> >>> Kernel side verifier allows us to do arithmetic computation using >>> two local variable >>> address or local variable address and R11. Therefore, we can compute >>> the location >>> of a local variable using: >>> >>> mark = &my_var_a - __builtin_frame_address(0); >>> >>> If the stack allocation is fixed (if the location is never reused), >>> the above 'mark' >>> can be uniquely identify a local variable. That's why I'm >>> interesting in it. However >>> I'm not sure whether the prerequestion is hold. >>> >>>> patch 2: >>>> do we really need to hack clang? >>>> Can you just define a function that aliases to intrinsic, >>>> like we do for ld_abs/ld_ind ? >>>> void bpf_store_half(void *skb, u64 off, u64 val) >>>> asm("llvm.bpf.store.half"); >>>> then no extra patches necessary. >>>> And for this: I tried this test function: void bpf_store_half(void *skb, int off, int val) asm("llvm.bpf.store.half"); int func() { bpf_store_half(0, 0, 0); return 0; } Compiled with: $ clang -g -target bpf -O2 -S -c test.c And get this: .text .globl func .align 8 func: # @func # BB#0: # %entry mov r1, 0 mov r2, 0 mov r3, 0 call llvm.bpf.store.half mov r0, 0 ret Without -S, it generate a function relocation: $ objdump -r ./test.o ./test.o: file format elf64-little RELOCATION RECORDS FOR [.text]: OFFSET TYPE VALUE 0000000000000018 UNKNOWN llvm.bpf.store.half It doesn't work as you suggestion. I think we still need to do something in clang frontend, or it can only be used in '.ll'. Thank you. -- 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/