From patchwork Mon Oct 14 19:25:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1176603 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-510934-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="rCMBkopw"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46sT6n5TrBz9sPJ for ; Tue, 15 Oct 2019 06:25:35 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :content-type:content-transfer-encoding:mime-version:subject :message-id:date:to; q=dns; s=default; b=StM7CpXu0W67jayWPB//3tK oG9nVn8rHNh1RMa0p2jXK+HeJNIhrXM+cbm78g5uV5RMj7jofPtu27pAt19VNxkz HRNlK+3uf8eK1iabHiXdMZWw/dsxDjYTMsWKoKBK/eNQPMS+zW8BpHbDIlwN1LeZ EN8wttbWwszu7LunWwKs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :content-type:content-transfer-encoding:mime-version:subject :message-id:date:to; s=default; bh=OGJ0gTzMfetTZaKnREGSimjiZdo=; b= rCMBkopwwS1+MJVVFdNqM4rH+68y25M/N9mFw/VKk1k5DbcNw89KVxKox8f983Tg xU/1V5F5PfyntNq7U6YC6T4CUGzSb0L/e1gAwtGpqQKAPj/aQAsHAnhM6zQcbp7m pwFloCKov6GaoQRv0bzx/iKjj0lTHbGsVTMWRGnxqCQ= Received: (qmail 42435 invoked by alias); 14 Oct 2019 19:25:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 42420 invoked by uid 89); 14 Oct 2019 19:25:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_COUK, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=HX-Languages-Length:2862, Minor, HX-Spam-Relays-External:ESMTPA X-HELO: smtp2.wavenetuk.net Received: from smtp.wavenetuk.net (HELO smtp2.wavenetuk.net) (195.26.37.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 14 Oct 2019 19:25:25 +0000 Received: from [192.168.1.212] (host81-138-1-83.in-addr.btopenworld.com [81.138.1.83]) by smtp2.wavenetuk.net (Postfix) with ESMTPA id BC4BD600110 for ; Mon, 14 Oct 2019 20:25:21 +0100 (BST) From: Iain Sandoe Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [Darwin, machopic 9/n, committed] Minor code clean-ups. Message-Id: <2203CDCE-B716-49F7-BFB0-994651A260BD@sandoe.co.uk> Date: Mon, 14 Oct 2019 20:25:18 +0100 To: GCC-patches Improve some comments, replace some asserts that have been in the code base for years with checking-asserts. Use unsigned ints for the picbase counters. tested on x86_64-darwin16, applied to mainline, Iain gcc/ChangeLog: 2019-10-14 Iain Sandoe * config/darwin.c: Use unsigned ints for the picbase label counters, initialise the vars explicitly. (update_pic_label_number_if_needed): Move a variable declaration to where it's needed. (machopic_output_function_base_name): Use a more strict checking assert, and and unsigned int for the picbase label counter. (machopic_get_function_picbase): Likewise. diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 8635fc2b44..1d386e0670 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -375,20 +375,22 @@ machopic_gen_offset (rtx orig) } } -static GTY(()) const char * function_base_func_name; -static GTY(()) int current_pic_label_num; -static GTY(()) int emitted_pic_label_num; - +static GTY(()) const char * function_base_func_name = NULL; +static GTY(()) unsigned current_pic_label_num = 0; +static GTY(()) unsigned emitted_pic_label_num = 0; + +/* We need to keep one picbase label per function, but (when we emit code + to reload the picbase for setjump receiver) we might need to check for + a second use. So, only update the picbase label counter when we see a + new function. When there's no function decl, we assume that the call is + from the x86 stub generation code. */ static void update_pic_label_number_if_needed (void) { - const char *current_name; - - /* When we are generating _get_pc thunks within stubs, there is no current - function. */ if (current_function_decl) { - current_name = + + const char *current_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)); if (function_base_func_name != current_name) { @@ -406,11 +408,11 @@ update_pic_label_number_if_needed (void) void machopic_output_function_base_name (FILE *file) { - /* If dynamic-no-pic is on, we should not get here. */ - gcc_assert (!MACHO_DYNAMIC_NO_PIC_P); + /* We should only get here for -fPIC. */ + gcc_checking_assert (MACHOPIC_PURE); update_pic_label_number_if_needed (); - fprintf (file, "L%d$pb", current_pic_label_num); + fprintf (file, "L%u$pb", current_pic_label_num); } char curr_picbasename[32]; @@ -418,11 +420,11 @@ char curr_picbasename[32]; const char * machopic_get_function_picbase (void) { - /* If dynamic-no-pic is on, we should not get here. */ - gcc_assert (!MACHO_DYNAMIC_NO_PIC_P); + /* We should only get here for -fPIC. */ + gcc_checking_assert (MACHOPIC_PURE); update_pic_label_number_if_needed (); - snprintf (curr_picbasename, 32, "L%d$pb", current_pic_label_num); + snprintf (curr_picbasename, 32, "L%u$pb", current_pic_label_num); return (const char *) curr_picbasename; }