From owner-freebsd-hackers@FreeBSD.ORG Sat Mar 2 17:36:12 2013 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 50629E77 for ; Sat, 2 Mar 2013 17:36:12 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 4D1C194A for ; Sat, 2 Mar 2013 17:36:10 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id TAA21721 for ; Sat, 02 Mar 2013 19:36:02 +0200 (EET) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1UBqLp-000Aty-OM for freebsd-hackers@FreeBSD.org; Sat, 02 Mar 2013 19:36:01 +0200 Message-ID: <5132387E.8010808@FreeBSD.org> Date: Sat, 02 Mar 2013 19:35:58 +0200 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130220 Thunderbird/17.0.3 MIME-Version: 1.0 To: freebsd-hackers@FreeBSD.org Subject: clang generated code sometimes confuses fbt X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=X-VIET-VPS Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Mar 2013 17:36:12 -0000 I observe the following problem. There are two tiny wrapper functions around a larger implementation function: int bpobj_iterate(bpobj_t *bpo, bpobj_itor_t func, void *arg, dmu_tx_t *tx) { return (bpobj_iterate_impl(bpo, func, arg, tx, B_TRUE)); } int bpobj_iterate_nofree(bpobj_t *bpo, bpobj_itor_t func, void *arg, dmu_tx_t *tx) { return (bpobj_iterate_impl(bpo, func, arg, tx, B_FALSE)); } On a clang compiled system: $ dtrace -l | fgrep bpobj_iterate 1483 fbt kernel bpobj_iterate_impl entry 1484 fbt kernel bpobj_iterate_impl return On a gcc compiled system: dtrace -l | fgrep bpobj_iterate 647 fbt kernel bpobj_iterate_impl entry 648 fbt kernel bpobj_iterate_impl return 20656 fbt kernel bpobj_iterate entry 20657 fbt kernel bpobj_iterate return 28426 fbt kernel bpobj_iterate_nofree entry 28427 fbt kernel bpobj_iterate_nofree return Examination reveals why that is so. clang: Dump of assembler code for function bpobj_iterate: 0xffffffff802d5a90 : mov $0x1,%r8d 0xffffffff802d5a96 : jmp 0xffffffff802d5aa0 gcc: Dump of assembler code for function bpobj_iterate: 0xffffffff802d3f43 : push %rbp 0xffffffff802d3f44 : mov %rsp,%rbp 0xffffffff802d3f47 : mov $0x1,%r8d 0xffffffff802d3f4d : callq 0xffffffff802d3787 0xffffffff802d3f52 : pop %rbp 0xffffffff802d3f53 : retq So quite obviously fbt can not really entry/return points for the clang function. This is not a big problem on its own, of course, but here is a bad twist. On the clang system: $ ctfdump -f /boot/kernel/kernel | fgrep bpobj_iterate [8975] FUNC (bpobj_iterate) returns: 24 args: (2601, 4824, 34, 2221) [13093] FUNC (bpobj_iterate_nofree) returns: 24 args: (2601, 4824, 34, 2221) Now that's the problem: fbt sees only bpobj_iterate_impl, but CTF data is generated/present only for bpobj_iterate and bpobj_iterate_nofree. On the gcc system: ctfdump -f /boot/kernel/kernel | fgrep bpobj_iterate [323] FUNC (bpobj_iterate_impl) returns: 1 args: (5153, 5661, 6, 5078, 1350) [10439] FUNC (bpobj_iterate) returns: 1 args: (5153, 5661, 6, 5078) [14377] FUNC (bpobj_iterate_nofree) returns: 1 args: (5153, 5661, 6, 5078) To summarize: I would be glad of either clang generated code was "fbt-friendly" or if ctf information was generated for bpobj_iterate_impl. Either is perfect for me. Now, I am not quite sure why ctfconvert skips bpobj_iterate_impl in the clang-generated code. Seems like some sort of a bug in ctfconvert. -- Andriy Gapon