From owner-freebsd-hackers@FreeBSD.ORG Mon Nov 19 00:01:46 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 50996258; Mon, 19 Nov 2012 00:01:46 +0000 (UTC) (envelope-from nparhar@gmail.com) Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by mx1.freebsd.org (Postfix) with ESMTP id 0B5D18FC12; Mon, 19 Nov 2012 00:01:45 +0000 (UTC) Received: by mail-pa0-f54.google.com with SMTP id kp6so3110756pab.13 for ; Sun, 18 Nov 2012 16:01:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=z+uze2VhRE828C0AayNcrT/ZzixhrZNGV5pQgbch1/c=; b=DgyWMVQ/KDFrSVjRidwTXB0jLdxEMAnud09OxHrc+0/FpkhndHMLfD2gRB4PKdPK0a k3Zu2ZXPtbDJvOuywYI2ZYLqIVHNcVJDoR6IJ8xcxNA5Qug6IxTsQJHNV7ij/zOdzzWV NlQf5YLUbrhQddybAPkqSeIc0Xsviy4aK+hqd6tq1vOJf2iTkaZnZWSWvQXI24gzzfGs tkZ+738Dhbgd2R9Je1ZPTKwADpuZ0xZ9KPh9lkSsv6PwppX3rOzauWxXN05ADiutWvsJ zyfT4cWkAXfKRzsRMlSb6F0cRE4lHTotR0UWIJhmA/KlEus80BpnnxRY7Y5RK26Huvt7 E+eA== Received: by 10.66.77.74 with SMTP id q10mr31039168paw.81.1353283305457; Sun, 18 Nov 2012 16:01:45 -0800 (PST) Received: from itx (c-24-6-45-85.hsd1.ca.comcast.net. [24.6.45.85]) by mx.google.com with ESMTPS id uk9sm5141272pbc.63.2012.11.18.16.01.42 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 18 Nov 2012 16:01:43 -0800 (PST) Date: Sun, 18 Nov 2012 16:01:37 -0800 From: Navdeep Parhar To: Dimitry Andric Subject: Re: clang mangling some static struct names? Message-ID: <20121119000137.GA1437@itx> Mail-Followup-To: Dimitry Andric , Roman Divacky , freebsd-hackers@freebsd.org References: <50A6A3BD.5000901@gmail.com> <20121116214919.GA41725@freebsd.org> <50A6B85F.6090707@gmail.com> <50A8E487.1020105@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50A8E487.1020105@FreeBSD.org> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-hackers@freebsd.org, Roman Divacky 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: Mon, 19 Nov 2012 00:01:46 -0000 On Sun, Nov 18, 2012 at 02:37:11PM +0100, Dimitry Andric wrote: > On 2012-11-16 23:04, Navdeep Parhar wrote: > >On 11/16/12 13:49, Roman Divacky wrote: > >>Yes, it does that. iirc so that you can have things like > >> > >>void foo(int cond) { > >> if (cond) { > >> static int i = 7; > >> } else { > >> static int i = 8; > >> } > >>} > >> > >>working correctly. > > > >It's not appending the .n everywhere. And when it does, I don't see any > >potential collision that it prevented by doing so. Instead, it looks > >like the .n symbol corresponds to the nth element in the structure (so > >this is not name mangling in the true sense). I just don't see the > >point in doing things this way. It is only making things harder for > >debuggers. > > I don't think the point is making things harder for debuggers, the point > is optimization. Since static variables and functions can be optimized > away, or arbitrarily moved around, you cannot count on those symbols > being there at all. I'd (maybe) buy your argument if the symbol wasn't there at all. But it's there, just with a .0 appended to it. It hasn't been moved around or optimized away. In fact, in the case of scsi_low_statics the compiler added extra noise to the binary (in the form of multiple scsi_low_statics.[0-4] symbols that no one except the compiler knows about). There doesn't seem to be *any* good reason for adding the .n to the symbols. What is the optimization being attempted here? I lost the ability to look up some symbols in kgdb and I'd like to know what I gained in the process :-) Regards, Navdeep