about summary refs log tree commit diff
path: root/src/rustllvm/Passes2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rustllvm/Passes2.cpp')
-rw-r--r--src/rustllvm/Passes2.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/rustllvm/Passes2.cpp b/src/rustllvm/Passes2.cpp
index c4ead0de5aa..dcc549b511f 100644
--- a/src/rustllvm/Passes2.cpp
+++ b/src/rustllvm/Passes2.cpp
@@ -1,5 +1,5 @@
 #include "llvm/Analysis/Passes.h"
-#include "llvm/Support/StandardPasses.h"
+#include "llvm/Support/PassManagerBuilder.h"
 #include "llvm/PassManager.h"
 #include "llvm-c/Core.h"
 #include <cstdlib>
@@ -8,22 +8,29 @@ using namespace llvm;
 
 extern "C" void LLVMAddStandardFunctionPasses(LLVMPassManagerRef PM,
     unsigned int OptimizationLevel) {
-  createStandardFunctionPasses(unwrap(PM), OptimizationLevel);
+  PassManagerBuilder PMBuilder;
+  PMBuilder.OptLevel = OptimizationLevel;
+  FunctionPassManager *FPM = (FunctionPassManager*) unwrap(PM);
+  PMBuilder.populateFunctionPassManager(*FPM);
 }
 
 extern "C" void LLVMAddStandardModulePasses(LLVMPassManagerRef PM,
     unsigned int OptimizationLevel, LLVMBool OptimizeSize,
     LLVMBool UnitAtATime, LLVMBool UnrollLoops, LLVMBool SimplifyLibCalls,
-    LLVMBool HaveExceptions, unsigned int InliningThreshold) {
-  Pass *InliningPass;
+    unsigned int InliningThreshold) {
+
+  PassManagerBuilder PMBuilder;
+  PMBuilder.OptLevel = OptimizationLevel;
+  PMBuilder.SizeLevel = OptimizeSize;
+  PMBuilder.DisableUnitAtATime = !UnitAtATime;
+  PMBuilder.DisableUnrollLoops = !UnrollLoops;
+
+  PMBuilder.DisableSimplifyLibCalls = !SimplifyLibCalls;
+
   if (InliningThreshold)
-    InliningPass = createFunctionInliningPass(InliningThreshold);
-  else
-    InliningPass = NULL;
+    PMBuilder.Inliner = createFunctionInliningPass(InliningThreshold);
 
-  createStandardModulePasses(unwrap(PM), OptimizationLevel, OptimizeSize,
-                             UnitAtATime, UnrollLoops, SimplifyLibCalls,
-                             HaveExceptions, InliningPass);
+  PassManager *MPM = (PassManager*) unwrap(PM);
+  PMBuilder.populateModulePassManager(*MPM);
 }
 
-