From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by sourceware.org (Postfix) with ESMTPS id A689B3858D20 for ; Mon, 8 Apr 2024 09:02:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A689B3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A689B3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712566941; cv=none; b=xmsky37zCuWOcjrmgQg4sw5V0TaSzQ3+5niOtD0nQ4ki/D8Q+qUlhn4XBObn5EaWm8MwbpOz587TRWqmy1tQD/TeouLFlQDYeRJGkD20MN3Sk1XjxGozJDhdfEFvObdErCa3UrfZZO/yYup2EzkYsCZHX5RfI9t4bJzcGaq1+m0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712566941; c=relaxed/simple; bh=ryWn6GXl88J0MhFwrrz8kjpQHYOuzACQISGZ7jVihIY=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=Jx2Ffk4RE8DfUINzX8MEsxiYJbX/swqZqm/HxJur5m1GNdjE9/rDL+0S3VUL13s22DGaElxSQvBftIqMrpNtGXl8JtS0TB3FQaiC60cA+2CKhOlDsPpkb9H7A3PrJ/hGsWQhkrnLyf5ocuFb7JZAIlCBK3kjNJO2zJAUSV4ntdw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-516d3a470d5so3415029e87.3 for ; Mon, 08 Apr 2024 02:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712566937; x=1713171737; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ZI2k1m4ts2qCKwyLGd2KSU9+O9TfF8LGB7L9PuN2Nb0=; b=TCBu623UUfvTYsCfxnrkb78tjU89LoMHckfQBN1iYG3OkFf8tIuClhQe9jwOfBTBHs UTwYfjPWGcaewXS3ecoXMA0ACxvlPX2Yd3Di2sfsOqB5jnQYtnKdSyTCeXGXQ5cba5yf KNxbcEwmzypE+ZkoJQucefs0yjBjApHhqLgya76H5Vhrtn1O6XrHHBXlef8Fez996K1P ANnQ75bCNnoNamlMeZSB3Lb2s9wygb10O3OwQobJgx1RuFHwSBiQ+jhWxDw7A1Q50yUm wjBGp2lxUhnYUuFGG5yyVaqXV8TXttxYSrcjE7RAXnkVUd3ouEnO4v7cilxf6wFi7zlV ywQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712566937; x=1713171737; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZI2k1m4ts2qCKwyLGd2KSU9+O9TfF8LGB7L9PuN2Nb0=; b=DbAGlCYc552I65PBNocnPLgvalSrDVurDJSnMwVl5MfPrp86YQ++XYR6vYlviVelQL tDCbZYL1xZwACYtt4yzLv9lm80XU6s82uFkMVlbwEsMlCi9N0GudSE832mAlXMLO6cfM AXeLYwSMUyUOe4XnnNRdE7dRJlM5toS4YTIRG5fF787YCmHYxapESq+Re5sznh9qBZRN 37uaZ74tTHj2+yMRZ7KZ68HdRynqhb2Ayv5yPyTu7skvWedOOdgg0GSFnflEehX6Ugui 7P6/MZahHcwZzsfYxiJw88kY9TqMAVn5viPNUBU/7Dmb8LnwUDF5xe71vNb3W3VGDJMj wzXQ== X-Gm-Message-State: AOJu0YxFtJOVRv0Jp/mRIwEgTuxOJhf+6VCBxpMc9r9VGQ/PsNKdqtXU zM4qhVk5WRFDFt0nJe/ZFwxDX/m5ZnfUlNyuD+DP5+2BfbiK0I0A7DErJ/AdzzFtEveY/hq2+hF VWcWkebxRPRQyVgFUJRJ3qh114O4= X-Google-Smtp-Source: AGHT+IFLz3Sl7y52Mri8Doxk/sxK8zzY51K4NXdDNx+GoHRdsM2MNi1tI/ylCg1cT9bbxjDp2YmWkRdi68mcZwDxwgM= X-Received: by 2002:a05:6512:2387:b0:513:de8d:203c with SMTP id c7-20020a056512238700b00513de8d203cmr6889655lfv.28.1712566936434; Mon, 08 Apr 2024 02:02:16 -0700 (PDT) MIME-Version: 1.0 References: <7b63c4ff-b32e-44ad-9b25-3f8f2d138056@irisa.fr> <71f1d47f-a687-4b68-8538-97eda5fb91ec@irisa.fr> In-Reply-To: <71f1d47f-a687-4b68-8538-97eda5fb91ec@irisa.fr> From: Richard Biener Date: Mon, 8 Apr 2024 11:02:05 +0200 Message-ID: Subject: Re: [gimple-ssa] result_decl and ssa_name To: Pierrick Philippe Cc: gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 Mon, Apr 8, 2024 at 10:47=E2=80=AFAM Pierrick Philippe wrote: > > On 06/04/2024 14:53, Richard Biener wrote: > > On Fri, Apr 5, 2024 at 3:44=E2=80=AFPM Pierrick Philippe > wrote: > > On 05/04/2024 14:46, Richard Biener wrote: > > On Fri, Apr 5, 2024 at 1:59=E2=80=AFPM Pierrick Philippe > wrote: > > Hi all, > > I do have a question regarding ssa_name and result_decl. > > For example on the following gimple function: > > int f () > { > int x; > int D.2747; > int _2; > > : > x_1 =3D 42; > _2 =3D x_1; > > : > : > return _2; > > } > > On the above example, using the macro SSA_NAME_VAR() on _2 does not > yield anything usable. > Neither to call ssa_default_def() on the result of the result_decl > obtain through macro DECL_RESULT(). > > Is there a way to get the ssa_name corresponding to the result_decl of a > function obtained through the use of macro DECL_RESULT() on a fn_decl? > And/or the other way around? I.e., from the returned ssa_name of a > function to the result_decl of that function? > > I totally might be missing something here, but I cannot figure out what. > > DECL_RESULT isn't always used (as in your example). Not all SSA names > have corresponding declarations, we have "anonymous" SSA names which > have a NULL_TREE SSA_NAME_VAR (such as the _2 in your example). > > I see, that makes so much more sense to me now. > > What do you try to find in the end? If you want to find all returns you = can > walk predecessors of EXIT_BLOCK and look at their last stmt whether they > are greturn statements. > > I am implementing a state_machine within the analyzer, and I am trying to= understand where would be the best place to propagate the state of the ret= urn value. > I intuitively thought it would be best to do so in the state_machine::on_= pop_frame() method, which is called by the analyzer between the two frames = of the caller and the callee. What I do have access to is the struct functi= on of the callee/caller, the gcall instruction in the caller and the callee= have been processed by my analysis. > > It might make sense to record the analysis of the return value in > meta-data that the analyzer keeps and access it that way. > Other than that you'd have to do it the way I said with finding the > greturn stmts again and look at what is returned there. > > That is what I had in mind, thanks for answering me. > > I do have another question though, how do you obtain the decl_context of = such an ssa_name? The DECL_CONTEXT macro is failing during the tree check a= nd I ha ve no idea how to know where a given ssa_name is declared without a= ccessing its inner var (through SSA_NAME_VAR). And this operation is failin= g on _i ssa_name trees. There is no DECL_CONTEXT for SSA names, if the name is anonymous (no SSA_NAME_VAR) then the context is implicityly the whole function, thus the FUNCTION_DECL. > > And to illustrate, here I do have the _2 ssa_name and its state which I k= now in that case should be propagate to the lhs of the caller gcall instruc= tion. > > Again I might be taking this in a wrong way. > > Richard. > > Thanks for your time, > > Pierrick