From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id D22723858C2C for ; Thu, 1 Feb 2024 18:32:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D22723858C2C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D22723858C2C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706812343; cv=none; b=q1f3jdHkOQQ9eGWCPUJVMhR22w3X2JXNemy1n+nLqybBfZ+c2tKYMAPhrz+z/ThNr93BeCItnqLr+T/NzJUf5C1fdpM4QLahxPpbBRCQhtmxOMbozGanIBjDJBP5OBxVactP/Wd3qagRYcVVMknFLbWzQpS+s53PvemXH8hur4M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706812343; c=relaxed/simple; bh=GkZnpkD6jM71MpFQk8nd3o7lGhW+gl51pPvFMz0s5Yo=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=fDrwZ/WFPE/GRjDIk1rgJjIoxen/qKzNZNMaPI3RxYdM+z9E4KbIieSi7f17563liISbLzF9DEpw9j1l11LTgKydOcJGhRjYtUb/kirXqua5DD23dWfqmdxIAjbz2wQQd5xRaI14/CdJvLn5qki9lPpcAkVYWhTcX/YjzjBimbc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706812341; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=YE8J16JV9aQi6UoVjY3gqtZ89zDtvPlq7z7V/XT6XU4=; b=YKeONMU9/y6ijHc1kAZyd3hCYFXs6P353KEA+stcQ1h99bGD1fVOh9sjEUIjr1gqEhl9LC RZ0vvTIv80E7y/zYfQSl9kbOJkThEuL3DbF2kL5aBieBwagmvA1HnuTyD6Eun1NK05pm7R W0YxfDS89A887sYXKmbYkiUsVlm/tsk= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-Nizlpu99MB2OiQ2iWgQ2XA-1; Thu, 01 Feb 2024 13:32:18 -0500 X-MC-Unique: Nizlpu99MB2OiQ2iWgQ2XA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 28AA61C04B56; Thu, 1 Feb 2024 18:32:18 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E030540C9444; Thu, 1 Feb 2024 18:32:17 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 411IVtp54078766 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 1 Feb 2024 19:31:55 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 411IVsHo4078765; Thu, 1 Feb 2024 19:31:54 +0100 Date: Thu, 1 Feb 2024 19:31:54 +0100 From: Jakub Jelinek To: "H.J. Lu" Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] x86-64: Find a scratch register for large model profiling Message-ID: Reply-To: Jakub Jelinek References: <20240201181530.99684-1-hjl.tools@gmail.com> MIME-Version: 1.0 In-Reply-To: <20240201181530.99684-1-hjl.tools@gmail.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Feb 01, 2024 at 10:15:30AM -0800, H.J. Lu wrote: > --- a/gcc/config/i386/i386.cc > +++ b/gcc/config/i386/i386.cc > @@ -22749,6 +22749,31 @@ current_fentry_section (const char **name) > return true; > } > > +/* Return an unused caller-saved register at entry for profile. */ > + > +static int > +x86_64_select_profile_regnum (bool r11_ok ATTRIBUTE_UNUSED) > +{ > + int i; Why not just return R10_REG here if flag_entry != 0 (i.e. keep existing behavior unless emitting profiler after prologue)? > + for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) > + if (GENERAL_REGNO_P (i) > +#ifdef NO_PROFILE_COUNTERS > + && (r11_ok || i != R11_REG) > +#else > + && i != R11_REG > +#endif > + && (!REX2_INT_REGNO_P (i) || TARGET_APX_EGPR) > + && !fixed_regs[i] > + && call_used_regs[i] > + && !df_regs_ever_live_p (i)) Also, isn't this too restrictive? I mean, all we care about is whether there is some register which is not live across the NOTE_INSN_PROLOG_END note, no? I.e. doesn't contain any of function's argument that are used later, and isn't set in the prologue to be used later. E.g. call used register which is just saved to stack in the prologue might be just fine. > + return i; > + > + sorry ("No register available for profiling %<-mcmodel=large%s%>", Diagnostics shouldn't start with capital letter. > + ix86_cmodel == CM_LARGE_PIC ? " -fPIC" : ""); > + > + return INVALID_REGNUM; > +} > + > /* Output assembler code to FILE to increment profiler label # LABELNO > for profiling a function entry. */ > void Jakub