@@ -271,6 +271,7 @@ pub struct ModuleConfig {
271271 no_integrated_as : bool ,
272272 embed_bitcode : bool ,
273273 embed_bitcode_marker : bool ,
274+ pub polly : bool ,
274275}
275276
276277impl ModuleConfig {
@@ -302,7 +303,8 @@ impl ModuleConfig {
302303 vectorize_loop : false ,
303304 vectorize_slp : false ,
304305 merge_functions : false ,
305- inline_threshold : None
306+ inline_threshold : None ,
307+ polly : false ,
306308 }
307309 }
308310
@@ -340,6 +342,8 @@ impl ModuleConfig {
340342
341343 self . merge_functions = sess. opts . optimize == config:: OptLevel :: Default ||
342344 sess. opts . optimize == config:: OptLevel :: Aggressive ;
345+ self . polly = sess. opts . cg . polly && !self . no_prepopulate_passes &&
346+ !sess. target . target . options . is_like_emscripten ;
343347 }
344348}
345349
@@ -567,8 +571,8 @@ unsafe fn optimize(cgcx: &CodegenContext,
567571
568572 if !config. no_verify { assert ! ( addpass( "verify" ) ) ; }
569573 if !config. no_prepopulate_passes {
570- llvm:: LLVMRustAddAnalysisPasses ( tm, fpm, llmod) ;
571- llvm:: LLVMRustAddAnalysisPasses ( tm, mpm, llmod) ;
574+ llvm:: LLVMRustAddAnalysisPasses ( tm, fpm, llmod, config . polly ) ;
575+ llvm:: LLVMRustAddAnalysisPasses ( tm, mpm, llmod, config . polly ) ;
572576 let opt_level = config. opt_level . unwrap_or ( llvm:: CodeGenOptLevel :: None ) ;
573577 with_llvm_pmb ( llmod, & config, opt_level, & mut |b| {
574578 llvm:: LLVMPassManagerBuilderPopulateFunctionPassManager ( b, fpm) ;
@@ -666,11 +670,12 @@ unsafe fn codegen(cgcx: &CodegenContext,
666670 unsafe fn with_codegen < F , R > ( tm : TargetMachineRef ,
667671 llmod : ModuleRef ,
668672 no_builtins : bool ,
673+ polly : bool ,
669674 f : F ) -> R
670675 where F : FnOnce ( PassManagerRef ) -> R ,
671676 {
672677 let cpm = llvm:: LLVMCreatePassManager ( ) ;
673- llvm:: LLVMRustAddAnalysisPasses ( tm, cpm, llmod) ;
678+ llvm:: LLVMRustAddAnalysisPasses ( tm, cpm, llmod, polly ) ;
674679 llvm:: LLVMRustAddLibraryInfo ( cpm, llmod, no_builtins) ;
675680 f ( cpm)
676681 }
@@ -765,7 +770,8 @@ unsafe fn codegen(cgcx: &CodegenContext,
765770 cursor. position ( ) as size_t
766771 }
767772
768- with_codegen ( tm, llmod, config. no_builtins , |cpm| {
773+ with_codegen ( tm, llmod, config. no_builtins , config. polly ,
774+ |cpm| {
769775 llvm:: LLVMRustPrintModule ( cpm, llmod, out. as_ptr ( ) , demangle_callback) ;
770776 llvm:: LLVMDisposePassManager ( cpm) ;
771777 } ) ;
@@ -783,7 +789,8 @@ unsafe fn codegen(cgcx: &CodegenContext,
783789 } else {
784790 llmod
785791 } ;
786- with_codegen ( tm, llmod, config. no_builtins , |cpm| {
792+ with_codegen ( tm, llmod, config. no_builtins , config. polly ,
793+ |cpm| {
787794 write_output_file ( diag_handler, tm, cpm, llmod, & path,
788795 llvm:: FileType :: AssemblyFile )
789796 } ) ?;
@@ -794,7 +801,8 @@ unsafe fn codegen(cgcx: &CodegenContext,
794801 }
795802
796803 if write_obj {
797- with_codegen ( tm, llmod, config. no_builtins , |cpm| {
804+ with_codegen ( tm, llmod, config. no_builtins , config. polly ,
805+ |cpm| {
798806 write_output_file ( diag_handler, tm, cpm, llmod, & obj_out,
799807 llvm:: FileType :: ObjectFile )
800808 } ) ?;
0 commit comments