Using the new pass manager, we recently ran across an interesting problem where some LTO optimization behaved differently on Windows versus Linux. We traced it down to differences in createConfig() in lld/ELF/LTO.cpp and lld/COFF/LTO.cpp. The ELF version has
c.PTO.LoopVectorization = c.OptLevel > 1;
c.PTO.SLPVectorization = c.OptLevel > 1;
but the COFF version does not. Eyeballing the two versions, it looks like there are probably a number of things that are unintentionally missing from the COFF version.
Arguably, vectorization enablement is a compiler setting that shouldn’t depend on the target environment, or even which linker is being used. Would it be better for such things to be moved into runNewPMPasses() in llvm/lib/LTO/LTOBackend.cpp?
Obviously I could submit a patch to do this for the vectorization settings, but there are quite a few other differences, and I don’t feel qualified to determine the proper resolution for all of them. Hence this post. It would be good if somebody knowledgeable could make some recommendations to bring the two environments back in line. (I didn’t even look at MachO, or any of the other linkers.)