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.133.124]) by sourceware.org (Postfix) with ESMTPS id A4F933948472 for ; Fri, 7 Oct 2022 04:08:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A4F933948472 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665115716; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Oem5tSFpjxhAB2NFVsfM2w6tD3JJwgkmEYg3Y/gMmxQ=; b=QF1wJ74ErdWdqVTxvoaNfp3CBeoRvrASTia045igAujA8EZ/jsY/Qh4bhzZCZqnpe07NfY 4MAOTQilszwfs/9fgGsm4Vmqtq2XhPCUTGE8Ymq8521mCHOYs0TYgUeQVnFimsnXvBCvGw rLKW6E34W5he8xAiR806x6NNnEpypI0= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-148-JOYmKiTwMGq1LSWXIIAIzQ-1; Fri, 07 Oct 2022 00:08:34 -0400 X-MC-Unique: JOYmKiTwMGq1LSWXIIAIzQ-1 Received: by mail-qk1-f200.google.com with SMTP id ay35-20020a05620a17a300b006cfc01b4436so2978414qkb.13 for ; Thu, 06 Oct 2022 21:08:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=Oem5tSFpjxhAB2NFVsfM2w6tD3JJwgkmEYg3Y/gMmxQ=; b=TLisqlYhVSGBarUckzelshjVDDgAhDeXyt6pv/TEv/z1ijf7uUSHoCD6SvQD5aUkjW Y3HNpVYqpyazTeqsayxAU2ekU34Tkuo8OGGbzqfUuGP/PC/EXsweH7Y2W9UnBwhD26Ts E06wBtOU/RV78+RUIadvta2PDaf2jVIvpWCwC8GMN8NFJ6PhCmpnv3rzu1Bj+mrP/N56 idf5JSu74xYOqhlDbt9t/iz14jnlYO6temctXs0xCSO8Dda+BBeDu/E69UpwoTEm6Z6e 4CgS79o9ZC92xDVMlYrKEMG6pKMqnGcE5oMreNk2ZM731IEdfVxNj8FunW4SVdIeZTF8 /aUA== X-Gm-Message-State: ACrzQf2C9DhanF6K52b0DTrDa8hHLosuGrDCVSme2IpjgUjyrLgdOUIz YwJY1cQ3Pt53EITF4O5/xmsQY5WqWABw/BJNwJHXBGyh3/CdjwHAEC/heJv2NUSKo5JpVJHu+Ud lbhWcQkUWWxPPkp/3+w== X-Received: by 2002:a05:620a:270b:b0:6ce:8cb:6fbe with SMTP id b11-20020a05620a270b00b006ce08cb6fbemr2569448qkp.180.1665115713980; Thu, 06 Oct 2022 21:08:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM53LER7D9wzH7TvJSYucz5w3ixLDya6doS/jRKkNWmEGw63kjbT48aD0SO3wGqL7CUxbCYGRw== X-Received: by 2002:a05:620a:270b:b0:6ce:8cb:6fbe with SMTP id b11-20020a05620a270b00b006ce08cb6fbemr2569442qkp.180.1665115713703; Thu, 06 Oct 2022 21:08:33 -0700 (PDT) Received: from [192.168.1.101] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id i13-20020a05620a248d00b006b5e296452csm1073002qkn.54.2022.10.06.21.08.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Oct 2022 21:08:33 -0700 (PDT) Message-ID: Date: Fri, 7 Oct 2022 00:08:31 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 Subject: Re: [PATCH] Set discriminators for call stmts on the same line within the same basic block To: Eugene Rozenfeld , "gcc-patches@gcc.gnu.org" References: From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP 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 10/6/22 23:50, Eugene Rozenfeld wrote: > Thank you for the review Jason. > > I fixed formatting and updated the commit description: OK. > ---------------------------- > > Call statements are possible split points of a basic block so they may end up > in different basic blocks by the time pass_ipa_auto_profile executes. > > This change will also simplify call site lookups since now location with discriminator > will uniquely identify the call site (no callee function name is needed). > > This change is based on commit 1e6c4a7a8fb8e20545bb9f9032d3854f3f794c18 > by Dehao Chen in vendors/google/heads/gcc-4_8. > > Tested on x86_64-pc-linux-gnu. > > gcc/ChangeLog: > * tree-cfg.cc (assign_discriminators): Set discriminators for call stmts > on the same line within the same basic block. > --- > gcc/tree-cfg.cc | 32 ++++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) > > diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc > index ade66c54499..f6a465f4c91 100644 > --- a/gcc/tree-cfg.cc > +++ b/gcc/tree-cfg.cc > @@ -1203,8 +1203,40 @@ assign_discriminators (void) > { > edge e; > edge_iterator ei; > + gimple_stmt_iterator gsi; > gimple *last = last_stmt (bb); > location_t locus = last ? gimple_location (last) : UNKNOWN_LOCATION; > + location_t curr_locus = UNKNOWN_LOCATION; > + int curr_discr = 0; > + > + /* Traverse the basic block, if two function calls within a basic block > + are mapped to the same line, assign a new discriminator because a call > + stmt could be a split point of a basic block. */ > + for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) > + { > + gimple *stmt = gsi_stmt (gsi); > + expanded_location curr_locus_e; > + if (curr_locus == UNKNOWN_LOCATION) > + { > + curr_locus = gimple_location (stmt); > + curr_locus_e = expand_location (curr_locus); > + } > + else if (!same_line_p (curr_locus, &curr_locus_e, gimple_location (stmt))) > + { > + curr_locus = gimple_location (stmt); > + curr_locus_e = expand_location (curr_locus); > + curr_discr = 0; > + } > + else if (curr_discr != 0) > + { > + location_t loc = gimple_location (stmt); > + location_t dloc = location_with_discriminator (loc, curr_discr); > + gimple_set_location (stmt, dloc); > + } > + /* Allocate a new discriminator for CALL stmt. */ > + if (gimple_code (stmt) == GIMPLE_CALL) > + curr_discr = next_discriminator_for_locus (curr_locus); > + } > > if (locus == UNKNOWN_LOCATION) > continue;