@@ -250,6 +250,7 @@ pub struct ModuleConfig {
250250 no_integrated_as : bool ,
251251 embed_bitcode : bool ,
252252 embed_bitcode_marker : bool ,
253+ pub polly : bool ,
253254}
254255
255256impl ModuleConfig {
@@ -281,7 +282,8 @@ impl ModuleConfig {
281282 vectorize_loop : false ,
282283 vectorize_slp : false ,
283284 merge_functions : false ,
284- inline_threshold : None
285+ inline_threshold : None ,
286+ polly : false ,
285287 }
286288 }
287289
@@ -319,6 +321,8 @@ impl ModuleConfig {
319321
320322 self . merge_functions = sess. opts . optimize == config:: OptLevel :: Default ||
321323 sess. opts . optimize == config:: OptLevel :: Aggressive ;
324+ self . polly = sess. opts . debugging_opts . polly && !self . no_prepopulate_passes &&
325+ !sess. target . target . options . is_like_emscripten ;
322326 }
323327}
324328
@@ -546,8 +550,8 @@ unsafe fn optimize(cgcx: &CodegenContext,
546550
547551 if !config. no_verify { assert ! ( addpass( "verify" ) ) ; }
548552 if !config. no_prepopulate_passes {
549- llvm:: LLVMRustAddAnalysisPasses ( tm, fpm, llmod) ;
550- llvm:: LLVMRustAddAnalysisPasses ( tm, mpm, llmod) ;
553+ llvm:: LLVMRustAddAnalysisPasses ( tm, fpm, llmod, config . polly ) ;
554+ llvm:: LLVMRustAddAnalysisPasses ( tm, mpm, llmod, config . polly ) ;
551555 let opt_level = config. opt_level . unwrap_or ( llvm:: CodeGenOptLevel :: None ) ;
552556 with_llvm_pmb ( llmod, & config, opt_level, & mut |b| {
553557 llvm:: LLVMPassManagerBuilderPopulateFunctionPassManager ( b, fpm) ;
@@ -645,11 +649,12 @@ unsafe fn codegen(cgcx: &CodegenContext,
645649 unsafe fn with_codegen < F , R > ( tm : TargetMachineRef ,
646650 llmod : ModuleRef ,
647651 no_builtins : bool ,
652+ polly : bool ,
648653 f : F ) -> R
649654 where F : FnOnce ( PassManagerRef ) -> R ,
650655 {
651656 let cpm = llvm:: LLVMCreatePassManager ( ) ;
652- llvm:: LLVMRustAddAnalysisPasses ( tm, cpm, llmod) ;
657+ llvm:: LLVMRustAddAnalysisPasses ( tm, cpm, llmod, polly ) ;
653658 llvm:: LLVMRustAddLibraryInfo ( cpm, llmod, no_builtins) ;
654659 f ( cpm)
655660 }
@@ -744,7 +749,8 @@ unsafe fn codegen(cgcx: &CodegenContext,
744749 cursor. position ( ) as size_t
745750 }
746751
747- with_codegen ( tm, llmod, config. no_builtins , |cpm| {
752+ with_codegen ( tm, llmod, config. no_builtins , config. polly ,
753+ |cpm| {
748754 llvm:: LLVMRustPrintModule ( cpm, llmod, out. as_ptr ( ) , demangle_callback) ;
749755 llvm:: LLVMDisposePassManager ( cpm) ;
750756 } ) ;
@@ -762,7 +768,8 @@ unsafe fn codegen(cgcx: &CodegenContext,
762768 } else {
763769 llmod
764770 } ;
765- with_codegen ( tm, llmod, config. no_builtins , |cpm| {
771+ with_codegen ( tm, llmod, config. no_builtins , config. polly ,
772+ |cpm| {
766773 write_output_file ( diag_handler, tm, cpm, llmod, & path,
767774 llvm:: FileType :: AssemblyFile )
768775 } ) ?;
@@ -773,7 +780,8 @@ unsafe fn codegen(cgcx: &CodegenContext,
773780 }
774781
775782 if write_obj {
776- with_codegen ( tm, llmod, config. no_builtins , |cpm| {
783+ with_codegen ( tm, llmod, config. no_builtins , config. polly ,
784+ |cpm| {
777785 write_output_file ( diag_handler, tm, cpm, llmod, & obj_out,
778786 llvm:: FileType :: ObjectFile )
779787 } ) ?;
0 commit comments