@@ -265,6 +265,7 @@ pub struct ModuleConfig {
265
265
no_integrated_as : bool ,
266
266
embed_bitcode : bool ,
267
267
embed_bitcode_marker : bool ,
268
+ pub polly : bool ,
268
269
}
269
270
270
271
impl ModuleConfig {
@@ -297,7 +298,8 @@ impl ModuleConfig {
297
298
vectorize_loop : false ,
298
299
vectorize_slp : false ,
299
300
merge_functions : false ,
300
- inline_threshold : None
301
+ inline_threshold : None ,
302
+ polly : false ,
301
303
}
302
304
}
303
305
@@ -336,6 +338,8 @@ impl ModuleConfig {
336
338
337
339
self . merge_functions = sess. opts . optimize == config:: OptLevel :: Default ||
338
340
sess. opts . optimize == config:: OptLevel :: Aggressive ;
341
+ self . polly = sess. opts . debugging_opts . polly && !self . no_prepopulate_passes &&
342
+ !sess. target . target . options . is_like_emscripten ;
339
343
}
340
344
}
341
345
@@ -568,8 +572,8 @@ unsafe fn optimize(cgcx: &CodegenContext,
568
572
|| config. obj_is_bitcode || config. emit_bc_compressed || config. embed_bitcode ) ;
569
573
let mut have_name_anon_globals_pass = false ;
570
574
if !config. no_prepopulate_passes {
571
- llvm:: LLVMRustAddAnalysisPasses ( tm, fpm, llmod) ;
572
- llvm:: LLVMRustAddAnalysisPasses ( tm, mpm, llmod) ;
575
+ llvm:: LLVMRustAddAnalysisPasses ( tm, fpm, llmod, config . polly ) ;
576
+ llvm:: LLVMRustAddAnalysisPasses ( tm, mpm, llmod, config . polly ) ;
573
577
let opt_level = config. opt_level . unwrap_or ( llvm:: CodeGenOptLevel :: None ) ;
574
578
let prepare_for_thin_lto = cgcx. lto == Lto :: Thin || cgcx. lto == Lto :: ThinLocal ||
575
579
( cgcx. lto != Lto :: Fat && cgcx. opts . debugging_opts . cross_lang_lto . enabled ( ) ) ;
@@ -702,11 +706,12 @@ unsafe fn codegen(cgcx: &CodegenContext,
702
706
unsafe fn with_codegen < ' ll , F , R > ( tm : & ' ll llvm:: TargetMachine ,
703
707
llmod : & ' ll llvm:: Module ,
704
708
no_builtins : bool ,
709
+ polly : bool ,
705
710
f : F ) -> R
706
711
where F : FnOnce ( & ' ll mut PassManager < ' ll > ) -> R ,
707
712
{
708
713
let cpm = llvm:: LLVMCreatePassManager ( ) ;
709
- llvm:: LLVMRustAddAnalysisPasses ( tm, cpm, llmod) ;
714
+ llvm:: LLVMRustAddAnalysisPasses ( tm, cpm, llmod, polly ) ;
710
715
llvm:: LLVMRustAddLibraryInfo ( cpm, llmod, no_builtins) ;
711
716
f ( cpm)
712
717
}
@@ -801,7 +806,8 @@ unsafe fn codegen(cgcx: &CodegenContext,
801
806
cursor. position ( ) as size_t
802
807
}
803
808
804
- with_codegen ( tm, llmod, config. no_builtins , |cpm| {
809
+ with_codegen ( tm, llmod, config. no_builtins , config. polly ,
810
+ |cpm| {
805
811
llvm:: LLVMRustPrintModule ( cpm, llmod, out. as_ptr ( ) , demangle_callback) ;
806
812
llvm:: LLVMDisposePassManager ( cpm) ;
807
813
} ) ;
@@ -819,15 +825,17 @@ unsafe fn codegen(cgcx: &CodegenContext,
819
825
} else {
820
826
llmod
821
827
} ;
822
- with_codegen ( tm, llmod, config. no_builtins , |cpm| {
828
+ with_codegen ( tm, llmod, config. no_builtins , config. polly ,
829
+ |cpm| {
823
830
write_output_file ( diag_handler, tm, cpm, llmod, & path,
824
831
llvm:: FileType :: AssemblyFile )
825
832
} ) ?;
826
833
timeline. record ( "asm" ) ;
827
834
}
828
835
829
836
if write_obj {
830
- with_codegen ( tm, llmod, config. no_builtins , |cpm| {
837
+ with_codegen ( tm, llmod, config. no_builtins , config. polly ,
838
+ |cpm| {
831
839
write_output_file ( diag_handler, tm, cpm, llmod, & obj_out,
832
840
llvm:: FileType :: ObjectFile )
833
841
} ) ?;
@@ -2221,7 +2229,8 @@ pub unsafe fn with_llvm_pmb(llmod: &llvm::Module,
2221
2229
llvm:: LLVMPassManagerBuilderSetDisableUnrollLoops ( builder, 1 ) ;
2222
2230
}
2223
2231
2224
- llvm:: LLVMRustAddBuilderLibraryInfo ( builder, llmod, config. no_builtins ) ;
2232
+ llvm:: LLVMRustAddBuilderLibraryInfo ( builder, llmod, config. no_builtins ,
2233
+ config. polly ) ;
2225
2234
2226
2235
// Here we match what clang does (kinda). For O0 we only inline
2227
2236
// always-inline functions (but don't add lifetime intrinsics), at O1 we
0 commit comments