[llvm-commits] [llvm-gcc-4.2] r79556 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp opts.c tree.c tree.h
Dale Johannesen
dalej at apple.com
Thu Aug 20 11:28:41 PDT 2009
Author: johannes
Date: Thu Aug 20 13:28:41 2009
New Revision: 79556
URL: http://llvm.org/viewvc/llvm-project?rev=79556&view=rev
Log:
Hook up -finline-limit so it controls llvm's inlining.
Mapping is not exact, to put it mildly. Should be
no functional change unless -finline-limit
(or --param max-inline-insns-auto) is used.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
llvm-gcc-4.2/trunk/gcc/opts.c
llvm-gcc-4.2/trunk/gcc/tree.c
llvm-gcc-4.2/trunk/gcc/tree.h
Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=79556&r1=79555&r2=79556&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Thu Aug 20 13:28:41 2009
@@ -351,6 +351,32 @@
#undef Declare2
}
+// GuessAtInliningThreshold - Figure out a reasonable threshold to pass llvm's
+// inliner. There are 12 user-settable gcc params that affect inlining. llvm
+// (so far) only has one knob; the param that corresponds most closely, and
+// which we use, is max-inline-insns-auto (set by -finline-limit, which is
+// what most users actually use). This maps only very approximately to what
+// llvm's inliner is doing, but it's the best we've got.
+static unsigned GuessAtInliningThreshold() {
+ unsigned threshold = 200;
+ // Get the default value for gcc's max-inline-insns-auto. This is the value
+ // after all language and target dependent changes to the global default are
+ // applied, but before parsing the command line.
+ unsigned default_miia = default_max_inline_insns_auto;
+ // See if the actual value is the same as the default.
+ unsigned miia = MAX_INLINE_INSNS_AUTO;
+ if (miia == default_miia) {
+ if (optimize_size || optimize < 3)
+ // Reduce inline limit.
+ threshold = 50;
+ } else {
+ // We have an overriding user-specified value. Multiply by 20/9, which is
+ // the Magic Number converting 90 to 200.
+ threshold = miia * 20 / 9;
+ }
+ return threshold;
+}
+
void llvm_initialize_backend(void) {
// Initialize the LLVM backend.
#define DoInit2(TARG, MOD) LLVMInitialize ## TARG ## MOD()
@@ -394,9 +420,6 @@
Args.push_back("--debug-pass=Structure");
if (flag_debug_pass_arguments)
Args.push_back("--debug-pass=Arguments");
- if (optimize_size || optimize < 3)
- // Reduce inline limit. Default limit is 200.
- Args.push_back("--inline-threshold=50");
if (flag_unwind_tables)
Args.push_back("--unwind-tables");
@@ -405,6 +428,12 @@
// purposes, and shouldn't really be for general use.
std::vector<std::string> ArgStrings;
+ if (flag_inline_trees > 1) {
+ unsigned threshold = GuessAtInliningThreshold();
+ std::string Arg("--inline-threshold="+utostr(threshold));
+ ArgStrings.push_back(Arg);
+ }
+
if (flag_limited_precision > 0) {
std::string Arg("--limit-float-precision="+utostr(flag_limited_precision));
ArgStrings.push_back(Arg);
Modified: llvm-gcc-4.2/trunk/gcc/opts.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/opts.c?rev=79556&r1=79555&r2=79556&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/opts.c (original)
+++ llvm-gcc-4.2/trunk/gcc/opts.c Thu Aug 20 13:28:41 2009
@@ -682,6 +682,12 @@
OPTIMIZATION_OPTIONS (optimize, optimize_size);
#endif
+ /* LLVM LOCAL begin hook up -finline-limit */
+ /* Remember the value of MAX_INLINE_INSNS_AUTO after applying target-dependent
+ changes to the defaults, but before command line options are parsed. */
+ default_max_inline_insns_auto = MAX_INLINE_INSNS_AUTO;
+ /* LLVM LOCAL end */
+
/* APPLE LOCAL begin AV 3846092 */
/* We have apple local patch to disable -fstrict-aliasing when -O2 is used.
However do not disable it when -ftree-vectorize is used. Clobber its value
Modified: llvm-gcc-4.2/trunk/gcc/tree.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/tree.c?rev=79556&r1=79555&r2=79556&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/tree.c (original)
+++ llvm-gcc-4.2/trunk/gcc/tree.c Thu Aug 20 13:28:41 2009
@@ -73,6 +73,13 @@
tree generic_block_literal_struct_type;
/* APPLE LOCAL end 6353006 */
+/* LLVM LOCAL begin */
+/* The value of MAX_INLINE_INSNS_AUTO after all target-dependent changes
+ are applied to the global default (which many targets do), but before
+ command line flags are handled. */
+unsigned default_max_inline_insns_auto;
+/* LLVM LOCAL end */
+
/* obstack.[ch] explicitly declined to prototype this. */
extern int _obstack_allocated_p (struct obstack *h, void *obj);
Modified: llvm-gcc-4.2/trunk/gcc/tree.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/tree.h?rev=79556&r1=79555&r2=79556&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/tree.h (original)
+++ llvm-gcc-4.2/trunk/gcc/tree.h Thu Aug 20 13:28:41 2009
@@ -4892,4 +4892,10 @@
/* APPLE LOCAL end radar 6300081 */
+/* LLVM LOCAL begin */
+/* The value of MAX_INLINE_INSNS_AUTO after all target-dependent changes
+ are applied to the global default (which many targets do), but before
+ command line flags are handled. */
+extern unsigned default_max_inline_insns_auto;
+/* LLVM LOCAL end */
#endif /* GCC_TREE_H */
More information about the llvm-commits
mailing list