diff options
author | Egor Bogatov <egorbo@gmail.com> | 2018-11-06 16:05:40 +0300 |
---|---|---|
committer | monojenkins <jo.shields+jenkins@xamarin.com> | 2018-11-06 16:05:40 +0300 |
commit | 14cb53030d1bbfbba7e90e1b2c53654a104bfdca (patch) | |
tree | 4659dc9af6dda02cd8a83ab5c8f1fb7600aba125 | |
parent | ce08c3263264559b9312e791db265ca951fab59c (diff) |
Don't override default LLVM's opt & llc args via llvmopts-add and llvmllc-add commands (#11556)
Don't override default LLVM's opt & llc args via llvmopts-add and llvmllc-add commands
Currently we can pass custom arguments to LLVM's `opt` and `llc` via:
```
mono --aot=llvm,llvmopts="...",llvmllc="..."
```
but those completely override the default arguments mono uses (some of them are required).
E.g. lets say I need to add `-foo` to both opt and llc, I should do:
```
mono --aot=llvm,llvmllc="**-foo** -march=x86-64 -mattr=sse4.1 -asm-verbose=false
-disable-gnu-eh-frame -enable-mono-eh-frame -mono-eh-frame-symbol=_mono_aot_p_eh_frame
-disable-tail-calls -no-x86-call-frame-opt -relocation-model=pic
-filetype=obj,llvmopts="**-foo** -O2 -disable-tail-calls"
```
So this PR introduces new commands `llvmopts-add` and `llvmllc-add` to be able to simply do:
`mono --aot=llvm,llvmopts-add="-foo",llvmllc-add="-foo"`
PS: let me know if you don't like the `-add` suffix
/cc: @migueldeicaza
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | man/mono.1 | 4 | ||||
-rw-r--r-- | mono/mini/aot-compiler.c | 10 |
3 files changed, 9 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore index ededfdb8205..1171a4110d3 100644 --- a/.gitignore +++ b/.gitignore @@ -133,3 +133,5 @@ tmpinst-dir.stamp msvc/scripts/inputs/ extensions-config.h *.mlpd +llvm/build/ +llvm/usr/ diff --git a/man/mono.1 b/man/mono.1 index 9b7f16116c4..a0a205a9bbb 100644 --- a/man/mono.1 +++ b/man/mono.1 @@ -215,14 +215,14 @@ and options. This feature is experimental. .TP .I llvmopts=[options] -Use this option to override the built-in set of flags passed to the +Use this option to add more flags to the built-in set of flags passed to the LLVM optimizer. The list of possible flags that can be passed can be obtained by calling the bundled .I opt program that comes with Mono. .TP .I llvmllc=[options] -Use this option to override the built-in set of flags passed to the +Use this option to add more flags to the built-in set of flags passed to the LLVM static compiler (llc). The list of possible flags that can be passed can be obtained by calling the bundled .I llc diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c index 10102343d82..845debf70ff 100644 --- a/mono/mini/aot-compiler.c +++ b/mono/mini/aot-compiler.c @@ -9243,9 +9243,7 @@ emit_llvm_file (MonoAotCompile *acfg) * return OverwriteComplete; * Here, if 'Earlier' refers to a memset, and Later has no size info, it mistakenly thinks the memset is redundant. */ - if (acfg->aot_opts.llvm_opts) { - opts = g_strdup (acfg->aot_opts.llvm_opts); - } else if (acfg->aot_opts.llvm_only) { + if (acfg->aot_opts.llvm_only) { // FIXME: This doesn't work yet opts = g_strdup (""); } else { @@ -9254,6 +9252,9 @@ emit_llvm_file (MonoAotCompile *acfg) #else opts = g_strdup ("-targetlibinfo -no-aa -basicaa -notti -instcombine -simplifycfg -inline-cost -inline -sroa -domtree -early-cse -lazy-value-info -correlated-propagation -simplifycfg -instcombine -simplifycfg -reassociate -domtree -loops -loop-simplify -lcssa -loop-rotate -licm -lcssa -loop-unswitch -instcombine -scalar-evolution -loop-simplify -lcssa -indvars -loop-idiom -loop-deletion -loop-unroll -memdep -gvn -memdep -memcpyopt -sccp -instcombine -lazy-value-info -correlated-propagation -domtree -memdep -adce -simplifycfg -instcombine -strip-dead-prototypes -domtree -verify"); #endif + if (acfg->aot_opts.llvm_opts) { + opts = g_strdup_printf ("%s %s", opts, acfg->aot_opts.llvm_opts); + } } command = g_strdup_printf ("\"%sopt\" -f %s -o \"%s\" \"%s\"", acfg->aot_opts.llvm_path, opts, optbc, tempbc); @@ -9318,8 +9319,7 @@ emit_llvm_file (MonoAotCompile *acfg) } if (acfg->aot_opts.llvm_llc) { - g_free (acfg->llc_args); - acfg->llc_args = g_string_new (acfg->aot_opts.llvm_llc); + g_string_append_printf (acfg->llc_args, " %s", acfg->aot_opts.llvm_llc); } command = g_strdup_printf ("\"%sllc\" %s -o \"%s\" \"%s.opt.bc\"", acfg->aot_opts.llvm_path, acfg->llc_args->str, output_fname, acfg->tmpbasename); |