From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6943 invoked by alias); 8 Nov 2019 08:28:52 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 6935 invoked by uid 89); 8 Nov 2019 08:28:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.9 required=5.0 tests=AWL,BAYES_00,KAM_SHORT,SPF_PASS autolearn=ham version=3.3.1 spammy=UD:su, wow, H*i:sk:ortv7fp, H*f:sk:ortv7fp X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Nov 2019 08:28:50 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id F3191ACAE; Fri, 8 Nov 2019 08:28:47 +0000 (UTC) Date: Fri, 08 Nov 2019 08:28:00 -0000 From: Richard Biener To: Alexandre Oliva cc: gcc-patches@gcc.gnu.org, ebotcazou@adacore.com, joseph@codesourcery.com Subject: Re: introduce -fcallgraph-info option In-Reply-To: Message-ID: References: <84223B6B-F6F0-4B94-835E-6661E1E1EB6A@suse.de> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SW-Source: 2019-11/txt/msg00575.txt.bz2 On Thu, 7 Nov 2019, Alexandre Oliva wrote: > On Nov 7, 2019, Richard Biener wrote: > > > (also raises the question why we have both -dumpbase and -auxbase ...) > > https://gcc.gnu.org/ml/gcc-patches/2002-08/msg00294.html > > This was before -dumpdir, however. > > Here's the current logic for aux_base_name: > > -c or -S with -o [odir/]obase.oext: [odir/]obase > otherwise, given input [idir/]ibase.iext: ibase > > Whereas the current logic for dump_base_name, once aux_base_name has > been determined as [auxdir/]auxbase, is: > > given -dumpbase ddir/dbase: ddir/dbase > otherwise, given -dumpdir ddir and -dumpbase dbase: ddir/dbase > otherwise, given -dumpbase dbase: [auxdir/]dbase > otherwise, given -dumpdir ddir: ddir/ibase.iext > otherwise: [auxdir/]ibase.iext > > Relevant cases to consider: (aux, dump) for each compilation with > CC='gcc -fstack-usage -fdump-tree-original' > > compiling without -o: (ibase, ibase.iext) > ex $CC -c srcdir/foo.c srcdir/x/bar.c > -> foo.o foo.su foo.c.#t.original > + bar.o bar.su bar.c.#t.original > > compiling with -o: ([odir/]obase, [odir/]ibase.iext) > ex $CC -c srcdir/foo.c -o objdir/foobaz.o -Dfoobaz > -> objdir/foobaz.o objdir/foobaz.su objdir/foo.c.#t.original > > compiling multiple sources with -dumpbase: (ibase, [ddir/]dbase) > ex $CC -dumpbase outdir/runme.dump -c srcdir/foo.c srcdir/x/bar.c > -> foo.o foo.su outdir/runme.dump.#t.original > + bar.o bar.su outdir/runme.dump.#t.original (dupe) > > compiling and linking with -o: (ibase, ibase.iext) > ex $CC -o outdir/runme srcdir/foo.c srcdir/x/bar.c > -> /tmp/temp().o foo.su foo.c.#t.original > + /tmp/temp().o bar.su bar.c.#t.original > + outdir/runme > > lto-recompiling and linking with -o: (/tmp/obase.temp().ltrans#.ltrans, odir/obase.ltrans#) > ex $CC -o outdir/runme ltobjdir/foo.o ltobjdir/bar.o -fdump-rtl-expand > -> /tmp/runme.temp().ltrans0.ltrans.o /tmp/runme.temp().ltrans0.ltrans.su > + outdir/runme.ltrans0.#r.expand > + outdir/runme > > lto-recompiling and linking without -o: (/tmp/temp().ltrans#.ltrans, /tmp/temp().ltrans#.o) > ex $CC ltobjdir/foo.o ltobjdir/bar.o -fdump-rtl-expand > -> /tmp/temp().ltrans0.ltrans.o /tmp/temp().ltrans0.ltrans.su > + /tmp/temp().ltrans0.#r.expand > + a.out > > > If we were to unify auxbase and dumpbase, I'd take the opportunity to > fix the -o objdir/foobaz.o compilation to output dumps named after > objdir/foobaz or objdir/foobaz-foo.c rather than ./foo.c; for > outdir/runme.dump to be used as a prefix for aux and dump names, so that > we wouldn't create and then overwrite outdir/runme.dump, and so that > other compilations of foo.c and bar.c wouldn't overwrite the .su files, > but rather create outdir/runme.dump-{foo,bar}.* dumps and aux files; and > likewise use outdir/runme.ltrans0 or a.out.ltrans0 for the .su and > .expand files. > > > The logic I suggest is involves combining some of the -auxbase and some > of the -dumpbase logic, namely: > > In the driver: > > compiling a single source idir/ibase.iext: > > -o odir/obase.oext specified: default -dumpdir odir -dumpbase obase.iext > -o obase.oext specified: default -dumpbase obase.iext > -o ibase.oext implied: default -dumpbase ibase.iext > > compiling multiple sources named as ibase.iext for linking: > > -dumpbase [ddir/]dbase specified: make it -dumpbase [ddir/]dbase-ibase.iext > -o odir/output specified: default -dumpdir odir -dumpbase output-ibase.iext > -o output specified: default -dumpbase output-ibase.iext > -o a.out implied: default -dumpbase a.out-ibase.iext > > LTO recompiling: > > same as above, with each ibase.iext set to ltrans# > > > In the compiler, set dump_base_name to: > > Given -dumpbase ddir/dbase: ddir/dbase > otherwise, given -dumpdir ddir and -dumpbase dbase: ddir/dbase > otherwise, given -dumpbase dbase: dbase > > and copy aux_base_name from dump_base_name, but if it ends in .iext, > drop the extension. > > The resulting behavior (aux_base_name, dump_base_name) > > compiling without -o: (ibase, ibase.iext) unchanged > ex $CC -c srcdir/foo.c srcdir/x/bar.c > -> foo.o foo.su foo.c.#t.original > + bar.o bar.su bar.c.#t.original > > compiling with -o: ([odir/]obase, [odir/]obase.iext) > ex $CC -c srcdir/foo.c -o objdir/foobaz.o -Dfoobaz > -> objdir/foobaz.o objdir/foobaz.su objdir/foobaz.c.#t.original > > compiling multiple sources with -dumpbase: ([ddir]/dbase, [ddir/]dbase) > ex $CC -dumpbase outdir/runme.dump -c srcdir/foo.c srcdir/x/bar.c > -> foo.o outdir/runme.dump-foo.su outdir/runme.dump-foo.c.#t.original > + bar.o outdir/runme.dump-bar.su outdir/runme.dump-bar.c.#t.original > > compiling and linking with -o: (outdir/runme-ibase, outdir/runme-ibase.iext) > ex $CC -o outdir/runme srcdir/foo.c srcdir/x/bar.c > -> /tmp/temp().o outdir/runme-foo.su outdir/runme-foo.c.#t.original > + /tmp/temp().o outdir/runme-bar.su outdir/runme-bar.c.#t.original > + outdir/runme > > lto-recompiling and linking with -o: (outdir/runme.ltrans#, outdir/runme.ltrans#) > ex $CC -o outdir/runme ltobjdir/foo.o ltobjdir/bar.o -fdump-rtl-expand > -> /tmp/runme.temp().ltrans0.ltrans.o outdir/runme.ltrans0.su > + outdir/runme.ltrans0.#r.expand > + outdir/runme > > lto-recompiling and linking without -o: (a.out.ltrans#, a.out.ltrans#) > ex $CC ltobjdir/foo.o ltobjdir/bar.o -fdump-rtl-expand > -> /tmp/temp().ltrans0.ltrans.o a.out.ltrans0.su > + a.out.ltrans0.#r.expand > + a.out Wow, thanks for the elaborate write-up! I wonder if we can cut&paste this into documentation somewhere appropriate, maybe there's already a section for "auxiliary compiler outputs". > I'm a little hesitant, this amounts to quite significant behavior > changes. Do these seem acceptable and desirable nevertheless? I think the current state is somewhat of a mess and in some cases confusing and your suggestion sounds like an overall improvement to me (you didn't actually suggest to remove either of the -dump{base,dir} -auxbase{-strip} options?) Of course, others please feel free to comment (but let's not start bikeshedding too much...). Thanks a lot! Richard.