This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Faster compilation speed
- From: Noel Yap <yap_noel at yahoo dot com>
- To: Mike Stump <mrs at apple dot com>, gcc at gcc dot gnu dot org
- Date: Fri, 9 Aug 2002 13:04:13 -0700 (PDT)
- Subject: Re: Faster compilation speed
Build speeds are most helped by minimizing the number
of files opened and closed during the build. I think
a good start would be to have preprocessed header
files. My idea would be to add options to cpp that
would have it produce preprocessed files. Doing so
would allow it to be easily integrated into a build
system like "make".
At first, I think all that's really needed is a cpp
option, say --preprocess-includes, that just goes
through and preprocesses the #include directives (eg
it doesn't preprocess #define's, #if's, ...).
Conceivably, this would also require some other
option, possibly --preprocessed-header-file-path, so
that it can recognize when to use existing
preprocessed header files.
MTC,
Noel
--- Mike Stump <mrs@apple.com> wrote:
> I'd like to introduce lots of various changes to
> improve compiler
> speed. I thought I should send out an email and see
> if others think
> this would be good to have in the tree. Also, if it
> is, I'd like to
> solicit any ideas others have for me to pursue. I'd
> be happy to do all
> the hard work, if you come up with the ideas! The
> target is to be 6x
> faster.
>
> The first realization I came to is that the only
> existing control for
> such things is -O[123], and having thought about it,
> I think it would
> be best to retain and use those flags. For minimal
> user impact, I
> think it would be good to not perturb existing users
> of -O[0123] too
> much, or at leaast, not at first. If we wanted to
> change them, I think
> -O0 should be the `fast' version, -O1 should be what
> -O0 does now with
> some additions around the edges, and -O2 and -O3
> also slide over (at
> least one). What do you think, slide them all over
> one or more, or
> just make -O0 do less, or...? Maybe we have a -O0.0
> to mean compile
> very quickly?
>
> Another question would be how many knobs should we
> have? At first, I
> am inclined to say just one. If we want, we can
> later break them out
> into more choices. I am mainly interested in a
> single knob at this
> point.
>
> Another question is, what should the lower limit be
> on uglifying code
> for the sake of compilation speed.
>
> Below are some concrete ideas so others can get a
> feel for the types of
> changes, and to comment on the flag and how it is
> used.
> While I give a specific example, I'm more interested
> in the upper level
> comments, than discussion of not combining temp
> slots.
>
> The use of a macro preprocessor symbol allows us to
> replace it with 0
> or 1, should we want to obtain a compiler that is
> unconditionally
> faster, or one that doesn't have any extra code in
> it.
>
> This change yields a 0.9% speed improvement when
> compiling expr.c. Not
> much, but if the compiler were 6x faster, this would
> be 5.5% change in
> compilation speed. The resulting code is worse, but
> not by much.
>
> So, let the discussion begin...
>
>
> Doing diffs in flags.h.~1~:
> *** flags.h.~1~ Fri Aug 9 10:17:36 2002
> --- flags.h Fri Aug 9 10:37:58 2002
> *************** extern int flag_signaling_nans;
> *** 696,699 ****
> --- 696,705 ----
> #define HONOR_SIGN_DEPENDENT_ROUNDING(MODE) \
> (MODE_HAS_SIGN_DEPENDENT_ROUNDING (MODE) &&
> !flag_unsafe_math_optimizations)
>
> + /* Nonzero for compiling as fast as we can. */
> +
> + extern int flag_speed_compile;
> +
> + #define SPEEDCOMPILE flag_speed_compile
> +
> #endif /* ! GCC_FLAGS_H */
> --------------
> Doing diffs in function.c.~1~:
> *** function.c.~1~ Fri Aug 9 10:17:36 2002
> --- function.c Fri Aug 9 10:37:58 2002
> *************** free_temp_slots ()
> *** 1198,1203 ****
> --- 1198,1206 ----
> {
> struct temp_slot *p;
>
> + if (SPEEDCOMPILE)
> + return;
> +
> for (p = temp_slots; p; p = p->next)
> if (p->in_use && p->level == temp_slot_level
> && ! p->keep
> && p->rtl_expr == 0)
> *************** free_temps_for_rtl_expr (t)
> *** 1214,1219 ****
> --- 1217,1225 ----
> {
> struct temp_slot *p;
>
> + if (SPEEDCOMPILE)
> + return;
> +
> for (p = temp_slots; p; p = p->next)
> if (p->rtl_expr == t)
> {
> *************** pop_temp_slots ()
> *** 1301,1311 ****
> {
> struct temp_slot *p;
>
> ! for (p = temp_slots; p; p = p->next)
> ! if (p->in_use && p->level == temp_slot_level
> && p->rtl_expr == 0)
> ! p->in_use = 0;
>
> ! combine_temp_slots ();
>
> temp_slot_level--;
> }
> --- 1307,1320 ----
> {
> struct temp_slot *p;
>
> ! if (! SPEEDCOMPILE)
> ! {
> ! for (p = temp_slots; p; p = p->next)
> ! if (p->in_use && p->level == temp_slot_level
> && p->rtl_expr ==
> 0)
> ! p->in_use = 0;
>
> ! combine_temp_slots ();
> ! }
>
> temp_slot_level--;
> }
> --------------
> Doing diffs in toplev.c.~1~:
> *** toplev.c.~1~ Fri Aug 9 10:17:40 2002
> --- toplev.c Fri Aug 9 11:31:50 2002
> *************** int flag_new_regalloc = 0;
> *** 894,899 ****
> --- 894,903 ----
>
> int flag_tracer = 0;
>
> + /* If nonzero, speed-up the compile as fast as we
> can. */
> +
> + int flag_speed_compile = 0;
> +
> /* Values of the -falign-* flags: how much to
> align labels in code.
> 0 means `use default', 1 means `don't align'.
> For each variable, there is an _log variant
> which is the power
> *************** display_help ()
> *** 3679,3684 ****
> --- 3683,3689 ----
>
> printf (_(" -O[number] Set
> optimization level to
> [number]\n"));
> printf (_(" -Os Optimize
> for space rather than
> speed\n"));
> + printf (_(" -Of Compile as
> fast as
> possible\n"));
> for (i = LAST_PARAM; i--;)
> {
> const char *description =
> compiler_params[i].help;
> *************** parse_options_and_default_flags
> (argc, a
> *** 4772,4777 ****
> --- 4777,4786 ----
> /* Optimizing for size forces
> optimize to be 2. */
> optimize = 2;
> }
> + else if ((p[0] == 'f') && (p[1] == 0))
> + {
> + flag_speed_compile = 1;
> + }
> else
> {
> const int optimize_val =
> read_integral_parameter (p, p -
> 2, -1);
> --------------
>
__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com