From patchwork Wed Oct 27 22:07:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 46723 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EB695385840D for ; Wed, 27 Oct 2021 22:07:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EB695385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635372479; bh=B2SjRePYpWRflHckARBoZ/uHMxihbmXvUUdkr0lOgDc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=WdO0t2w5zjZqoVo+Gg9V0Ac0imXSmIfqrpJKFLJAeHpuX34wYMeFjjiJimXoGH2te BHStMBEJl/6C0hgOE0dcQtNS542lQSNlwTZ7B9wxrCe/e0gpgs/d/uNgeoIwB23wFv JofnPBAoRnsH5kxzBlyNadW49Y0cgfvJ3UcK7HMY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id 9A4F83858006 for ; Wed, 27 Oct 2021 22:07:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A4F83858006 Received: by mail-pj1-x1031.google.com with SMTP id t5-20020a17090a4e4500b001a0a284fcc2so6299476pjl.2 for ; Wed, 27 Oct 2021 15:07:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=B2SjRePYpWRflHckARBoZ/uHMxihbmXvUUdkr0lOgDc=; b=1asmCABjIlF71j7Ukhw98olqJJgfBJF+HSFQT+K47ibhaGr1KLulYUlYafvRUYVH+L uMVRykLhSlrd8kyZOxOmxSE6hxeO4JQw6Cx6JOSwwo8nAmtShfEX8HUEOgWajTA1mAhV Dqw7EJFF8JO5wxCMrz/6IH1LMPthHHeRoYyONl+CVbMVV2hGxycGvn+sXi2aslMJTaSZ MEOt3SDsG1qIvmHuso5/jR1mDvKQr8jAFjzMuzHZ8dOsUFUHnc8KeW5xx0E+Hz8EYzmv QmQ9hPe9tTqn02k9QdYN4EfxihLIa6+JW3b/H3uRpRQD+az2CKYg/C7SfTY43OjkDxaH HPgw== X-Gm-Message-State: AOAM531B2blFQy8svkoMsMKb/u5S0x9CaW7eGCvvp+HzBYYCl3B1Zcwu Fm/UNAbL6DrKBLC+DyuAIBQBEWUWA/k= X-Google-Smtp-Source: ABdhPJxTFqBNYqPebngFmYI5K2p47zmnft4tLJR9gEL9vW4gl/5uhymzMWU0/lkmEAv25v5XR3jfSA== X-Received: by 2002:a17:902:bd94:b0:13f:f96c:aa22 with SMTP id q20-20020a170902bd9400b0013ff96caa22mr382537pls.43.1635372434352; Wed, 27 Oct 2021 15:07:14 -0700 (PDT) Received: from localhost ([2409:10:24a0:4700:e8ad:216a:2a9d:6d0c]) by smtp.gmail.com with ESMTPSA id j8sm883025pfe.105.2021.10.27.15.07.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 15:07:13 -0700 (PDT) To: GCC patches Subject: [PATCH] or1k: Add return address argument to _mcount call Date: Thu, 28 Oct 2021 07:07:09 +0900 Message-Id: <20211027220709.750104-1-shorne@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Stafford Horne via Gcc-patches From: Stafford Horne Reply-To: Stafford Horne Cc: Openrisc Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This fixes an issue in the glibc port I am working on where the build fails due to the warning: error: calling ‘__builtin_return_address’ with a nonzero argument is unsafe [-Werror=frame-address] This is due to how the current implementation of _mcount in glibc uses __builtin_return_address with a count argument of 1. Fix that by passing the value of LR_REGNUM to the _mcount function, effectivtly providing the value _mcount is after. This is an ABI change, but I think it's OK because the glibc port for or1k is not yet upstreamed. Also, I think just adding an argument should not break anything anyway. gcc/ChangeLog: * config/or1k/or1k.h (PROFILE_HOOK): Add return address argument to _mcount. --- gcc/config/or1k/or1k.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/config/or1k/or1k.h b/gcc/config/or1k/or1k.h index fe01ab81ead..4603cb67160 100644 --- a/gcc/config/or1k/or1k.h +++ b/gcc/config/or1k/or1k.h @@ -387,9 +387,10 @@ do { \ profiling a function entry. */ #define PROFILE_HOOK(LABEL) \ { \ - rtx fun; \ + rtx fun, ra; \ + ra = get_hard_reg_initial_val (Pmode, LR_REGNUM); \ fun = gen_rtx_SYMBOL_REF (Pmode, "_mcount"); \ - emit_library_call (fun, LCT_NORMAL, VOIDmode); \ + emit_library_call (fun, LCT_NORMAL, VOIDmode, ra, Pmode); \ } /* All the work is done in PROFILE_HOOK, but this is still required. */