From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id BC1B5385E83D for ; Thu, 1 Jul 2021 12:53:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BC1B5385E83D Received: by mail-ed1-x52f.google.com with SMTP id h2so8301039edt.3 for ; Thu, 01 Jul 2021 05:53:25 -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=eaWNzMTc0MyI63Oq7our8aD+qRo5sSBh+cz8lD1X5go=; b=ZgIlmL9p6ho5yL7uW+94wY9yDwR1FuxoR/wty02gkmzRByd3xq/ZBEqWqA2J1k4XoD wi5KPiD/i3a0EkB1CaijOJwe2vWfwBCf45okwdyA+hGaX0+nuA9mbyL/DBCOlcohi+gj z4vFFKfn3JJZfR5DTMyzO4cXb3FH0C3FEDbwlC0ZwPqpEGwDMZomKiNH8C9UHFxwZIs3 i/R6udP92OTEJcLpRImB0VrWBHf1EwKol74cG54dxsgJaadshBv8ILaluYxHUKkiz0OF FDAJMMdDViKdNfC3egAgtCSdPwI8QV+Z/v8vXTDonMW8X6aCcZSY0XP+9qgKfPbsm75w 6g6g== X-Gm-Message-State: AOAM530Kj/NKn7AhV99afcl3BmGtkn2BfhbOIZvEwRMASRjCrgCktfyE EAWITQ1ZAm2ilrXisrV7/9yx8sTQJCveaGUibgA= X-Google-Smtp-Source: ABdhPJw905dHYNpBxUyJWZuAwNQjXN8oq4MIXnKjNoXlkeLfOuhnEpm9bWl+yCVD3GTnZzDCGzOouL2tDVN9/iyQ9ac= X-Received: by 2002:a05:6402:42c9:: with SMTP id i9mr54098475edc.61.1625144004731; Thu, 01 Jul 2021 05:53:24 -0700 (PDT) MIME-Version: 1.0 References: <20210630053529.26581-1-tbsaunde@tbsaunde.org> <20210630053529.26581-2-tbsaunde@tbsaunde.org> <907daf69d72fedce3dd9ee8a9dccc59d7d22a08a.camel@redhat.com> In-Reply-To: From: Richard Biener Date: Thu, 1 Jul 2021 14:53:13 +0200 Message-ID: Subject: Re: [PATCH 2/4] allow poisoning input_location in ranges it should not be used To: Trevor Saunders Cc: David Malcolm , GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Thu, 01 Jul 2021 12:53:28 -0000 On Thu, Jul 1, 2021 at 12:16 PM Trevor Saunders wrote: > > On Wed, Jun 30, 2021 at 11:13:23AM -0400, David Malcolm wrote: > > On Wed, 2021-06-30 at 01:35 -0400, Trevor Saunders wrote: > > > This makes it possible to assert if input_location is used during the > > > lifetime > > > of a scope. This will allow us to find places that currently use it > > > within a > > > function and its callees, or prevent adding uses within the lifetime > > > of a > > > function after all existing uses are removed. > > > > > > bootstrapped and regtested on x86_64-linux-gnu, ok? > > > > > > Trev > > > > [...snip...] > > > > > diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c > > > index d58586f2526..3f68d1d79eb 100644 > > > --- a/gcc/diagnostic.c > > > +++ b/gcc/diagnostic.c > > > @@ -1835,7 +1835,7 @@ internal_error (const char *gmsgid, ...) > > > auto_diagnostic_group d; > > > va_list ap; > > > va_start (ap, gmsgid); > > > - rich_location richloc (line_table, input_location); > > > + rich_location richloc (line_table, UNKNOWN_LOCATION); > > > diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_ICE); > > > va_end (ap); > > > > > > > I actually make use of this in the analyzer: the analyzer sets > > input_location to stmt->location when analyzing a given stmt - that > > way, if the analyzer ICEs, the ICE is shown at the code construct that > > crashed the analyzer. > > > > This behavior is useful to me, and would be lost with the proposed > > patch. > > I made this change because otherwise if the compiler ICE's while access > to input_location is blocked we end up infinitely recursing complaining > we can't access it while trying to say where the last error was. I was > nervous about the change before, and now I agree we need something > else. > > > Is there a better way of doing what I'm doing? > > > > Is the long-term goal of the patch kit to reduce our reliance on global > > variables? Are we ultimately still going to need a variable for "where > > to show the ICE if gcc crashes"? (perhaps stashing it in the > > diagnostic_context???) > > Yes, the goal is ultimately removal of global state, however I'm not > really ure what the better approach to your problem is, after all even > moving it to the diagnostic context is sort of a global state, and sort > of dupplicates input_location. That said it is somewhat more > constrained, so if it removes usage of input_location perhaps its > worthwhile? Reduction of global state is of course good - but in particular input_location should be something only used during parsing because it's a quite broken concept otherwise. And fiddling with it tends to be quite fragile... for example see g:7d6f7e92c3b737736a2d8ff97a71af9f230c2f88 for the "fun" you can have with "stale" values in input_location ... IMHO users should have their own "copy", for example the gimplifier instead of mucking with and using input_location could use a similar state in its gimplify_ctx. Richard. > Sorry I'm not yet sure what to propose here. > > Trev > > > > > Hope this is constructive > > Dave > >