While debugging a problem in our back-end, I want to temporarily remove JUST ‘-vectorize’ and ‘-vectorize-slp’ from the flags passed with ‘-cc1’, but I want to leave all the other command-line options the same. But when I use:
clang -S -O3 -fno-vectorize -fno-slp-vectorize foo.c
it is still inserting ‘-vectorize -vectorize-slp’. The code in ‘Clang.cpp’ for this is at line #4858 (on the v6.0 branch):
// Enable vectorization per default according to the optimization level
// selected. For optimization levels that want vectorization we use the alias
// option to simplify the hasFlag logic.
bool EnableVec = shouldEnableVectorizerAtOLevel(Args, false);
OptSpecifier VectorizeAliasOption =
EnableVec ? options::OPT_O_Group : options::OPT_fvectorize;
if (Args.hasFlag(options::OPT_fvectorize, VectorizeAliasOption,
// -fslp-vectorize is enabled based on the optimization level selected.
bool EnableSLPVec = shouldEnableVectorizerAtOLevel(Args, true);
OptSpecifier SLPVectAliasOption =
EnableSLPVec ? options::OPT_O_Group : options::OPT_fslp_vectorize;
if (Args.hasFlag(options::OPT_fslp_vectorize, SLPVectAliasOption,
but this is ignoring the ‘-fno-*’ flags and overriding because of the presence of ‘-O3’ and the defaults for ‘-O3’.
Am I just using ‘clang’ incorrectly, and if so, how can I achieve what I am trying to achieve? I don’t want to use ‘-O0’ or ‘-O1’ because I still want all of the other options passed as usual with ‘-cc1’ as would normally be passed with ‘-O3’. I am not just debugging one file, but would like to build hundreds of sources with the amended options by just changing some variables in the Makefiles to see what the impact is.