From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by sourceware.org (Postfix) with ESMTPS id 14BCF3858D33 for ; Sat, 6 Apr 2024 12:53:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 14BCF3858D33 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 14BCF3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712408004; cv=none; b=OOKy8A0v1J2zD5IJph9JOGN9gD0vgV619AgePR42m84MG1QCl58NtBnGvyUB5w3nJ2XKgcp/JAah5MLOD0i9Cli7SocDSRcsuDwEQdp6/kdaIN6xyRT3lChLJ1c0VYY0GGY0EtokB9WqWdTrkFitpcJGfadU877/PbIRfB0Mov8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712408004; c=relaxed/simple; bh=TIvWnk1LSuP/t71UWw5IMrW94GPwT2JH5ET/sFrmguA=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=VzmoHIWWZlilHGciQmHt4XoF23RCqRBb76leORfEnpyF21/vUTsgMXgB9Ey9pfiYtemBHPV/VxjS5GpAPYAAiVsOjMKW9ZQoWAMdwZM1YjLil8WJFScC/GHXljFUJnssNlzEFTYIYAaVCh8Hc8HmQHUgNsDqf4enI6hrz7YxHrg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2d4a8bddc21so39996291fa.0 for ; Sat, 06 Apr 2024 05:53:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712407999; x=1713012799; 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=YnOdJMWQMOuTiPc3DpFtvWEcIPHKeMNJiCbhUT1fVPM=; b=dcRmRFdDk6o8BT7Jp4C6689xetqK76+yXVTIUOsal2qAuUQ/31Njwf/15NpwYG2T1A 1VzmX279JHL5gTuiJ0uPYMlmTISjqqNCbBEykFZfYiI1AMQX/dhxIf2MVt6aIXG5jeaO gX5LS+1r2hnCuZ16eHa6mBcWOWfW6sA+mujbsKd32yzcETPKYpTNcJotvTbCcT1ZqwMI NnQqAERQ/emm0bxonZ+dPt7+9zf5hhEKUyx71YdnqgZE3AjWioZ8GiQC1XCTaMuunR9e 5qh0IPHeqTeLbRQmt3WwDt1DMywRCI78a6s5fkF16q8Khcah/BpVfsEk/V2hDQdtd8eq MsYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712407999; x=1713012799; 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=YnOdJMWQMOuTiPc3DpFtvWEcIPHKeMNJiCbhUT1fVPM=; b=lV7U6ExrilrRDn0pkcC2g/x06ayruZvr8D2a6u3e5sL6Eh2RWhlvgYOjZ8tntbR5a4 td+1FVJZImzPD37OVXUGjodz3JrdrzblYGWZ9JKYdjGY3/T1V19GKrPIr3eAHrxiQfHo 7+QsELS6+ul3oZGYALqIuQkZ73vbWOw4VG79U/77nxOrYbDoFWmVdjBdE/aAc4r40/F1 ep4CB5dXQnZZZ9DbuwcqBe+4jjVUzg35mwGzJaPMfJDV0G6s0kaUiMOFJ1kYqgjzQcla 4bOrfyNZ2eq3dXY3OWOm4OxHG1SgxnMJD7Z3BW795OvMK+q//Un49fDWhURW5gaTLtnF OGDQ== X-Gm-Message-State: AOJu0YwhsVezcnmLePx3Joeg21fglveucMQBAi7wamE7Ts+83B+ZqSjr CRbMuuSAnF3eEEwLkIxVZfghhF7m0k+WXr5dCEHGY+BPkzYmoxD+j+WRhSXoP8qLc64KLr4SFkA F8NSbfFiB650xSt+svbu38mqeIwY= X-Google-Smtp-Source: AGHT+IGmwehobnnfsNaPv8YIMpq2GV6EAAsbUmxZxcA304eePPR9ZcKpjiYZICc2tDMNFwGdBiGConDqzSlyNeSsYP0= X-Received: by 2002:a05:6512:60f:b0:516:9fdc:2621 with SMTP id b15-20020a056512060f00b005169fdc2621mr2880761lfe.0.1712407999106; Sat, 06 Apr 2024 05:53:19 -0700 (PDT) MIME-Version: 1.0 References: <7b63c4ff-b32e-44ad-9b25-3f8f2d138056@irisa.fr> In-Reply-To: From: Richard Biener Date: Sat, 6 Apr 2024 14:53:08 +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.7 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 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. > 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