From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id D91723857C61; Tue, 30 Mar 2021 11:20:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D91723857C61 Received: by mail-ed1-x533.google.com with SMTP id bf3so17745572edb.6; Tue, 30 Mar 2021 04:20:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CZDzNxZUTzBkUnBkpMzL1mJNMnWtRrqgapVN+mNQffk=; b=O9K+kVOtZ0tsVrXb9oISq455DgkhA7RByurT+63XX/nLDRI72WZ0f3uxPfAME8kPn/ gmHkcZQpNb9Y/rj2HHZxa3EhsnUE38NR8HHTQ+aQEpZZZQbg6mLFkkN9vP1xGhf9Gg6R 7aKpQVjPvlNsIT+qINF22LRBCe+OJrjci/Uj3XR4pPoFO58XbgOCDPMLSq7/8nj1rABU tG3dPjal2vGHCzosTgvGwIc/ueQrttosHwbPHxiugRksZyiIjgzoal0MppHNEq+Uo7Ul fKCa1qWNwdZ2oxwaNRGO2y4fTYAK2n/k4Sh34Kn2L1gSzNU49+EuTZS2tawJQNjPJR2U IquA== X-Gm-Message-State: AOAM532B3Gl/Dw6NsQYp05dwJe3ivROt0SJbfbu+PUGPqanoiP3eak0N IfE4rJ66QayQ3Er2hZEiOAY4miOrx6mOrnQxOqngknKk X-Google-Smtp-Source: ABdhPJyMgQDKrpBsnuGdn74jKqSOkPdt+dEg2GHrofAlef1N7NjjQPmCdpbUEkaQeDmigxcupdSb1jq/9X7/BAFGQwo= X-Received: by 2002:a05:6402:22f6:: with SMTP id dn22mr32567156edb.214.1617103214659; Tue, 30 Mar 2021 04:20:14 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Tue, 30 Mar 2021 13:20:03 +0200 Message-ID: Subject: Re: Question about points-to analysis, global variables, IPA, and field sensitivity To: Erick Ochoa Cc: GCC Development Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.1 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Mar 2021 11:20:17 -0000 On Tue, Mar 30, 2021 at 10:52 AM Erick Ochoa via Gcc wrote: > > Hi, > > I am looking at the points-to analysis in GCC and I found the > following comment in tree-ssa-structalias.c: > > /* Collect field information. */ > if (use_field_sensitive > && var_can_have_subvars (decl) > /* ??? Force us to not use subfields for globals in IPA mode. > Else we'd have to parse arbitrary initializers. */ > && !(in_ipa_mode > && is_global_var (decl))) > > > From what I understand here the points-to analysis is explicitly not > using field sensitivity for global variables when in IPA. I am > wondering, > 0) Is "initializers" here talking about brace initializers? Or are > "initializers" a little bit more abstract and refer to anything that > can initialize a field? Like struct->field = function()? initializers refers to static initializers (DECL_INITIAL) on global variables which satisfy the property of being assemblyable by varasm but can have some arbitrary GENERIC structure in their field initializers (like address calculations). > 1) How much work would it be to parse initializers? It should be pretty straight-forward to come up with sth conservative. To make it optimal is a little harder but maybe not so much. Straight-forward would be to generate constraints from DECL_INITIAL in a non-field-sensitive manner and then assign each subfield of the constraint variable this non-field sensitive solution. Basically do get_constraint_for_rhs (DECL_INITIAL (decl), &rhsc); process_all_all_constraints (&lhsc, &rhsc); and then go improve get_constraint_for_1 to handle CONSTRUCTOR (otherwise you'll get ANYTHING as fallback for everything it does not handle). Then there's the missing initializer bits which get zero which means NULL init (but when not considering field sensitive processing that's likely superfluous unless you want precise modeling of NULL) > 2) How would global structs which are not initialized using > initializers be handled? Would all fields get assigned NULL at the > global variable level, but then as other fields get assigned we just > create new constraints with the correct offsets? If the global is module local we should initialize it with NULL, yes. If it is not module local it should be initialized with NONLOCAL (that's both what should currently happen correctly - it's needed for non-field-sensitive init as well). > > Thanks!