From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33956 invoked by alias); 23 Oct 2019 13:35:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 33948 invoked by uid 89); 23 Oct 2019 13:35:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=H*RU:sk:mailout, HX-Spam-Relays-External:sk:mailout X-HELO: out2-smtp.messagingengine.com Received: from out2-smtp.messagingengine.com (HELO out2-smtp.messagingengine.com) (66.111.4.26) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Oct 2019 13:35:39 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id DAE1E21AF1; Wed, 23 Oct 2019 09:35:36 -0400 (EDT) Received: from imap1 ([10.202.2.51]) by compute4.internal (MEProxy); Wed, 23 Oct 2019 09:35:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyken.rs; h= mime-version:message-id:in-reply-to:references:date:from:to:cc :subject:content-type; s=fm1; bh=5mJAOlN7X/Y/q/YTgNfhLnqidoe6XAU O3/mYEPofpMg=; b=DBf1vtDoOCSUyIt546wGvZIODni8KCmSK2022Qyi2YHJ0bO Xi4d4044arpXrfCP/FLrqmu7H/Med8RdlWxdsrAmd6oFfFbprjACF4vdc2CKWUT5 LOG/GyvqXjQ0+YDxNPpBr+wmmD2+/bN2l96IkPrSIeSzOtLSjny37m/eUeSitkM6 wVLDDctHOI6cpGxJnT5U2/w7bfXqIWHAfPEOz0Myspsk61+kXr/XnQy/B+L9Ugl+ P731VMzvH3QR2PbvvnSUfI4KPqLhL6324t9qDLetNDsbf74HK9fFsUjgTd0g5rb1 vOuV1eoWziCXSLKrCC/i9o6lAj3gdJVN2+KHMnQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=5mJAOl N7X/Y/q/YTgNfhLnqidoe6XAUO3/mYEPofpMg=; b=O4M+AhN2IeKR3x3yHDqAzY O9eYdWl0WpG2eOvCm83Exe3zVaSbtkt8743Cw0R++23vHdLB1RUTPAcECB1DztV8 C0VEj9WEvCVlmlqx4VBzQ85N6KARkWz5wa8gBf/nVeM+aLidak5X7QHdYCVCRuSs RAt3CTn0suK97BbEthY4sLM+QG6f8BnVJYB0QaCh1wfUZYUmBCsrPexqLzpJARHK ITaQ9FqELIqyovqb318lC0ng7FAfapl3NdRuRTPHQLJxPgIXwwcCbRbryfqNH+dK coVMbiSW76t7/d132CTmOKZTdXgKl6E5zSDD5qayU6mYxyU3D+Gh7yv0aSjik7ig == X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrkeelgdeijecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderreejnecuhfhrohhmpedfgfguuhgr rhguqdfoihhhrghiuceuuhhrthgvshgtuhdfuceovgguugihsgeslhihkhgvnhdrrhhsqe enucfrrghrrghmpehmrghilhhfrhhomhepvgguugihsgeslhihkhgvnhdrrhhsnecuvehl uhhsthgvrhfuihiivgeptd Received: by mailuser.nyi.internal (Postfix, from userid 501) id 0A661C200A4; Wed, 23 Oct 2019 09:35:35 -0400 (EDT) User-Agent: Cyrus-JMAP/3.1.7-470-gedfae93-fmstable-20191021v4 Mime-Version: 1.0 Message-Id: In-Reply-To: References: Date: Wed, 23 Oct 2019 14:29:00 -0000 From: "Eduard-Mihai Burtescu" To: "Ian Lance Taylor" Cc: gcc-patches , "Ian Lance Taylor" Subject: =?UTF-8?Q?Re:_[PATCH]_Refactor_rust-demangle_to_be_independent_of_C++_de?= =?UTF-8?Q?mangling.?= Content-Type: text/plain X-SW-Source: 2019-10/txt/msg01654.txt.bz2 On Tue, Oct 22, 2019, at 9:39 PM, Ian Lance Taylor wrote: > I have to assume that C++ demangling is still quite a bit more common > than Rust demangling, so it's troubling that it looks like we're going > to do extra work for each symbol that starts with _ZN, which is not a > particularly uncommon prefix for a C++ mangled name. Is there some > way we can quickly separate out Rust symbols? Or should we try C++ > demangling first? > > Ian > I definitely agree, I don't want to make demangling plain C++ symbols significantly slower. The old code was also doing extra work, at least in the AUTO_DEMANGLING mode, but less than the parse_ident loop in this patch. I've come up with an extra quick check that regular C++ symbols won't pass most of the time and placed it before the parse_ident loop, that should make it comparable with the old implementation, and tests pass just fine with the extra check. The diff is below, but if you want me to send a combined patch, or anything else for that matter, please let me know. diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c index da707dbab9b..4cb189c4019 100644 --- a/libiberty/rust-demangle.c +++ b/libiberty/rust-demangle.c @@ -384,6 +384,14 @@ rust_demangle_callback (const char *mangled, int options, return 0; rdm.sym_len--; + /* Legacy Rust symbols also always end with a path segment + that encodes a 16 hex digit hash, i.e. '17h[a-f0-9]{16}'. + This early check, before any parse_ident calls, should + quickly filter out most C++ symbols unrelated to Rust. */ + if (!(rdm.sym_len > 19 + && !strncmp (&rdm.sym[rdm.sym_len - 19], "17h", 3))) + return 0; + do { ident = parse_ident (&rdm);