From owner-p4-projects@FreeBSD.ORG Tue May 18 16:12:11 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A031E16A4D3; Tue, 18 May 2004 16:12:09 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2525816A4D6 for ; Tue, 18 May 2004 16:12:08 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id C0B0E43ED0 for ; Tue, 18 May 2004 15:42:28 -0700 (PDT) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i4IMdXGe043851 for ; Tue, 18 May 2004 15:39:33 -0700 (PDT) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i4IMdWR5043848 for perforce@freebsd.org; Tue, 18 May 2004 15:39:32 -0700 (PDT) (envelope-from peter@freebsd.org) Date: Tue, 18 May 2004 15:39:32 -0700 (PDT) Message-Id: <200405182239.i4IMdWR5043848@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 53013 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2004 23:12:12 -0000 http://perforce.freebsd.org/chv.cgi?CH=53013 Change 53013 by peter@peter_daintree on 2004/05/18 15:39:14 make profiling actually work. It seems that gcc isn't prepared for mcount to trash any of the scratch registers. Affected files ... .. //depot/projects/hammer/sys/amd64/include/profile.h#14 edit Differences ... ==== //depot/projects/hammer/sys/amd64/include/profile.h#14 (text+ko) ==== @@ -76,9 +76,43 @@ #define FUNCTION_ALIGNMENT 4 -#define _MCOUNT_DECL static __inline void _mcount +#define _MCOUNT_DECL \ +static void _mcount(uintfptr_t frompc, uintfptr_t selfpc) __unused; \ +static void _mcount #ifdef __GNUC__ +#define MCOUNT __asm (" \n\ + .globl .mcount \n\ + .type .mcount @function \n\ +.mcount: \n\ + pushq %rbp \n\ + movq %rsp, %rbp \n\ + pushq %rdi \n\ + pushq %rsi \n\ + pushq %rdx \n\ + pushq %rcx \n\ + pushq %r8 \n\ + pushq %r9 \n\ + movq 8(%rbp),%rsi \n\ + movq (%rbp),%rdi \n\ + movq 8(%rdi),%rdi \n\ + call _mcount \n\ + popq %r9 \n\ + popq %r8 \n\ + popq %rcx \n\ + popq %rdx \n\ + popq %rsi \n\ + popq %rdi \n\ + leave \n\ + ret \n\ + .size .mcount, . - .mcount"); +#if 0 +/* + * We could use this, except it doesn't preserve the registers that were + * being passed with arguments to the function that we were inserted + * into. I've left it here as documentation of what the code above is + * supposed to do. + */ #define MCOUNT \ void \ mcount() \ @@ -97,10 +131,11 @@ * the caller's frame pointer. The caller's raddr is in the \ * caller's frame following the caller's caller's frame pointer.\ */ \ - __asm("movq (%%rbp),%0" : "=r" (frompc)); \ + __asm("movq (%%rbp),%0" : "=r" (frompc)); \ frompc = ((uintfptr_t *)frompc)[1]; \ _mcount(frompc, selfpc); \ } +#endif #else /* __GNUC__ */ #define MCOUNT \ void \