about summary refs log tree commit diff
path: root/src/rustllvm/PassWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-05-12 16:23:15 +0000
committerbors <bors@rust-lang.org>2018-05-12 16:23:15 +0000
commitc0cea750a0a10a0ed5a101839e37968d87f8ef9d (patch)
tree26403b7bfa1eadbb59b4debf8529bb1779d3c063 /src/rustllvm/PassWrapper.cpp
parente6db79f2ca07e4e533f4e940462a42f1093e52f3 (diff)
parenta70ef4cb49295563a09b254de4751c016c79e262 (diff)
downloadrust-c0cea750a0a10a0ed5a101839e37968d87f8ef9d.tar.gz
rust-c0cea750a0a10a0ed5a101839e37968d87f8ef9d.zip
Auto merge of #50684 - nikic:prepare-thinlto, r=nagisa
Set PrepareForThinLTO flag when using ThinLTO

The LLVM PassManager has a PrepareForThinLTO flag, which is intended for use when compilation occurs in conjunction with linking by ThinLTO. The flag has two effects:

 * The NameAnonGlobal pass is run after all other passes, which ensures that all globals have a name.
 * In optimized builds, a number of late passes (mainly related to vectorization and unrolling) are disabled, on the rationale that these a) will increase codesize of the intermediate artifacts and b) will be run by ThinLTO again anyway.

This patch enables the use of PrepareForThinLTO if Thin or ThinLocal linking is used.

The background for this change is the CI failure in #49479, which we assume to be caused by the NameAnonGlobal pass not being run. As this changes which passes LLVM runs, this might have performance (or other) impact, so we want to land this separately.
Diffstat (limited to 'src/rustllvm/PassWrapper.cpp')
-rw-r--r--src/rustllvm/PassWrapper.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
index 382ef2cc407..8593f543619 100644
--- a/src/rustllvm/PassWrapper.cpp
+++ b/src/rustllvm/PassWrapper.cpp
@@ -428,13 +428,16 @@ extern "C" void LLVMRustAddAnalysisPasses(LLVMTargetMachineRef TM,
 
 extern "C" void LLVMRustConfigurePassManagerBuilder(
     LLVMPassManagerBuilderRef PMBR, LLVMRustCodeGenOptLevel OptLevel,
-    bool MergeFunctions, bool SLPVectorize, bool LoopVectorize,
+    bool MergeFunctions, bool SLPVectorize, bool LoopVectorize, bool PrepareForThinLTO,
     const char* PGOGenPath, const char* PGOUsePath) {
   // Ignore mergefunc for now as enabling it causes crashes.
   // unwrap(PMBR)->MergeFunctions = MergeFunctions;
   unwrap(PMBR)->SLPVectorize = SLPVectorize;
   unwrap(PMBR)->OptLevel = fromRust(OptLevel);
   unwrap(PMBR)->LoopVectorize = LoopVectorize;
+#if LLVM_VERSION_GE(4, 0)
+  unwrap(PMBR)->PrepareForThinLTO = PrepareForThinLTO;
+#endif
 
 #ifdef PGO_AVAILABLE
   if (PGOGenPath) {