From patchwork Thu Jul 7 10:43:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 1653469 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=VgXTlyOY; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4LdtMM4VV6z9s07 for ; Thu, 7 Jul 2022 20:44:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C6C213851A9C for ; Thu, 7 Jul 2022 10:44:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6C213851A9C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1657190668; bh=3Dl2IMU7bHMA03MOB9k2B7Acvxib/xqq2YnwssW+tfg=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=VgXTlyOY3HKOW9kkufTnjs5wyYxWx4AViXL6bF/3cZT1u78jYC06t7Eb/iX6Q4ILs FaEDj3l2HmIbevDAxE7EEB5nlZvYTnmXqiOAP/CqnFCzAq9PYg/E7mUIdX42RBb7oG QWf8RYjSmdPygWObpwG2disGadqT4/vtMBcldtBM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id 8B97C3858D32 for ; Thu, 7 Jul 2022 10:44:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8B97C3858D32 Received: by mail-ej1-x634.google.com with SMTP id a9so1957264ejf.6 for ; Thu, 07 Jul 2022 03:44:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=3Dl2IMU7bHMA03MOB9k2B7Acvxib/xqq2YnwssW+tfg=; b=IHggWb1aObS1E9OW3ALbd0SQS4ztXVy9Rxt2dJIWugpRBVdvklavIktIbyhJn2OBEH EYCNSXt4DcZk+V69j+WJdkbJnpq5IvHK7ldgg4va3VwYb2jwwoFwZCCWK65BGk96duR6 Id/J/65PzcSS7tvvQTUmuYj1+FpzL9PY8m4d2gBExfKVLIG0wvvvb2k5q+onnpZZtVqP QxPTs6Lw+PhMJH1xAdxH9h1jdmNFd21b1FEtanOmbh01QAa9kOokYmAXX05arI5cWKd6 WVJf5t/owMXAqGMZiavH9+lFtqNvg23UT/kWokmk7zTzka4BDLZel6oWQp8pZNAchC7j rtPA== X-Gm-Message-State: AJIora8X/D09+qrN0oXsCoGl7udRPNNo6yYi85yNeygrvVvmS+p1MeK6 zRe1G1ORi0/QNmtPRsKnaAhEKokiVOGhnzqFAnXDI4aINnBAmA== X-Google-Smtp-Source: AGRyM1uPFmtUle/XHA18l+N3LkkIvf8UwIhx6Py0DyoJClyV6u3YpSGL5G+LTiEy3clcRJSW3Pq8HVX8eN5CTxydAzM= X-Received: by 2002:a17:906:8a72:b0:72b:cff:5382 with SMTP id hy18-20020a1709068a7200b0072b0cff5382mr2862783ejc.360.1657190645976; Thu, 07 Jul 2022 03:44:05 -0700 (PDT) MIME-Version: 1.0 Date: Thu, 7 Jul 2022 16:13:30 +0530 Message-ID: Subject: [statistics.cc] ICE in get_function_name with fortran test-case To: gcc Patches , Richard Biener X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Prathamesh Kulkarni via Gcc-patches From: Prathamesh Kulkarni Reply-To: Prathamesh Kulkarni Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, My recent commit to emit asm name with -fdump-statistics-asmname caused following ICE for attached fortran test case. during IPA pass: icf power.fppized.f90:6:26: 6 | END SUBROUTINE power_print | ^ internal compiler error: Segmentation fault 0xfddc13 crash_signal ../../gcc/gcc/toplev.cc:322 0x7f6f940de51f ??? ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0 0xfc909d get_function_name ../../gcc/gcc/statistics.cc:124 0xfc929f statistics_fini_pass_2(statistics_counter**, void*) ../../gcc/gcc/statistics.cc:175 0xfc94a4 void hash_table::traverse_noresize(void*) ../../gcc/gcc/hash-table.h:1084 0xfc94a4 statistics_fini_pass() ../../gcc/gcc/statistics.cc:219 0xef12bc execute_todo ../../gcc/gcc/passes.cc:2142 This happens because fn was passed NULL in get_function_name. The patch adds a check to see if fn is NULL before checking for DECL_ASSEMBLER_NAME_SET_P, which fixes the issue. In case the fn is NULL, it calls function_name(NULL) as per old behavior, which returns "(nofn)". Bootstrap+tested on x86_64-linux-gnu. OK to commit ? Thanks, Prathamesh diff --git a/gcc/statistics.cc b/gcc/statistics.cc index 6c21415bf65..01ad353e3a9 100644 --- a/gcc/statistics.cc +++ b/gcc/statistics.cc @@ -121,7 +121,7 @@ static const char * get_function_name (struct function *fn) { if ((statistics_dump_flags & TDF_ASMNAME) - && DECL_ASSEMBLER_NAME_SET_P (fn->decl)) + && fn && DECL_ASSEMBLER_NAME_SET_P (fn->decl)) { tree asmname = decl_assembler_name (fn->decl); if (asmname)