@@ -271,6 +271,7 @@ pub struct ModuleConfig {
271
271
no_integrated_as : bool ,
272
272
embed_bitcode : bool ,
273
273
embed_bitcode_marker : bool ,
274
+ pub polly : bool ,
274
275
}
275
276
276
277
impl ModuleConfig {
@@ -302,7 +303,8 @@ impl ModuleConfig {
302
303
vectorize_loop : false ,
303
304
vectorize_slp : false ,
304
305
merge_functions : false ,
305
- inline_threshold : None
306
+ inline_threshold : None ,
307
+ polly : false ,
306
308
}
307
309
}
308
310
@@ -340,6 +342,8 @@ impl ModuleConfig {
340
342
341
343
self . merge_functions = sess. opts . optimize == config:: OptLevel :: Default ||
342
344
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 ;
343
347
}
344
348
}
345
349
@@ -567,8 +571,8 @@ unsafe fn optimize(cgcx: &CodegenContext,
567
571
568
572
if !config. no_verify { assert ! ( addpass( "verify" ) ) ; }
569
573
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 ) ;
572
576
let opt_level = config. opt_level . unwrap_or ( llvm:: CodeGenOptLevel :: None ) ;
573
577
with_llvm_pmb ( llmod, & config, opt_level, & mut |b| {
574
578
llvm:: LLVMPassManagerBuilderPopulateFunctionPassManager ( b, fpm) ;
@@ -666,11 +670,12 @@ unsafe fn codegen(cgcx: &CodegenContext,
666
670
unsafe fn with_codegen < F , R > ( tm : TargetMachineRef ,
667
671
llmod : ModuleRef ,
668
672
no_builtins : bool ,
673
+ polly : bool ,
669
674
f : F ) -> R
670
675
where F : FnOnce ( PassManagerRef ) -> R ,
671
676
{
672
677
let cpm = llvm:: LLVMCreatePassManager ( ) ;
673
- llvm:: LLVMRustAddAnalysisPasses ( tm, cpm, llmod) ;
678
+ llvm:: LLVMRustAddAnalysisPasses ( tm, cpm, llmod, polly ) ;
674
679
llvm:: LLVMRustAddLibraryInfo ( cpm, llmod, no_builtins) ;
675
680
f ( cpm)
676
681
}
@@ -765,7 +770,8 @@ unsafe fn codegen(cgcx: &CodegenContext,
765
770
cursor. position ( ) as size_t
766
771
}
767
772
768
- with_codegen ( tm, llmod, config. no_builtins , |cpm| {
773
+ with_codegen ( tm, llmod, config. no_builtins , config. polly ,
774
+ |cpm| {
769
775
llvm:: LLVMRustPrintModule ( cpm, llmod, out. as_ptr ( ) , demangle_callback) ;
770
776
llvm:: LLVMDisposePassManager ( cpm) ;
771
777
} ) ;
@@ -783,7 +789,8 @@ unsafe fn codegen(cgcx: &CodegenContext,
783
789
} else {
784
790
llmod
785
791
} ;
786
- with_codegen ( tm, llmod, config. no_builtins , |cpm| {
792
+ with_codegen ( tm, llmod, config. no_builtins , config. polly ,
793
+ |cpm| {
787
794
write_output_file ( diag_handler, tm, cpm, llmod, & path,
788
795
llvm:: FileType :: AssemblyFile )
789
796
} ) ?;
@@ -794,7 +801,8 @@ unsafe fn codegen(cgcx: &CodegenContext,
794
801
}
795
802
796
803
if write_obj {
797
- with_codegen ( tm, llmod, config. no_builtins , |cpm| {
804
+ with_codegen ( tm, llmod, config. no_builtins , config. polly ,
805
+ |cpm| {
798
806
write_output_file ( diag_handler, tm, cpm, llmod, & obj_out,
799
807
llvm:: FileType :: ObjectFile )
800
808
} ) ?;
0 commit comments