File tree 4 files changed +28
-1
lines changed
4 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -586,9 +586,21 @@ pub(crate) fn run_pass_manager(
586
586
// LTO-specific optimization passes that LLVM provides.
587
587
//
588
588
// This code is based off the code found in llvm's LTO code generator:
589
- // tools/lto /LTOCodeGenerator.cpp
589
+ // llvm/lib/LTO /LTOCodeGenerator.cpp
590
590
debug ! ( "running the pass manager" ) ;
591
591
unsafe {
592
+ if !llvm:: LLVMRustHasModuleFlag (
593
+ module. module_llvm . llmod ( ) ,
594
+ "LTOPostLink" . as_ptr ( ) . cast ( ) ,
595
+ 11 ,
596
+ ) {
597
+ llvm:: LLVMRustAddModuleFlag (
598
+ module. module_llvm . llmod ( ) ,
599
+ llvm:: LLVMModFlagBehavior :: Error ,
600
+ "LTOPostLink\0 " . as_ptr ( ) . cast ( ) ,
601
+ 1 ,
602
+ ) ;
603
+ }
592
604
if llvm_util:: should_use_new_llvm_pass_manager (
593
605
& config. new_llvm_pass_manager ,
594
606
& cgcx. target_arch ,
Original file line number Diff line number Diff line change @@ -326,6 +326,15 @@ pub unsafe fn create_module<'ll>(
326
326
)
327
327
}
328
328
329
+ if sess. opts . debugging_opts . virtual_function_elimination {
330
+ llvm:: LLVMRustAddModuleFlag (
331
+ llmod,
332
+ llvm:: LLVMModFlagBehavior :: Error ,
333
+ "Virtual Function Elim\0 " . as_ptr ( ) . cast ( ) ,
334
+ 1 ,
335
+ ) ;
336
+ }
337
+
329
338
llmod
330
339
}
331
340
Original file line number Diff line number Diff line change @@ -1936,6 +1936,7 @@ extern "C" {
1936
1936
name : * const c_char ,
1937
1937
value : u32 ,
1938
1938
) ;
1939
+ pub fn LLVMRustHasModuleFlag ( M : & Module , name : * const c_char , len : size_t ) -> bool ;
1939
1940
1940
1941
pub fn LLVMRustMetadataAsValue < ' a > ( C : & ' a Context , MD : & ' a Metadata ) -> & ' a Value ;
1941
1942
Original file line number Diff line number Diff line change @@ -672,6 +672,11 @@ extern "C" void LLVMRustAddModuleFlag(
672
672
unwrap (M)->addModuleFlag (MergeBehavior, Name, Value);
673
673
}
674
674
675
+ extern " C" bool LLVMRustHasModuleFlag (LLVMModuleRef M, const char *Name,
676
+ size_t Len) {
677
+ return unwrap (M)->getModuleFlag (StringRef (Name, Len)) != nullptr ;
678
+ }
679
+
675
680
extern " C" LLVMValueRef LLVMRustMetadataAsValue (LLVMContextRef C, LLVMMetadataRef MD) {
676
681
return wrap (MetadataAsValue::get (*unwrap (C), unwrap (MD)));
677
682
}
You can’t perform that action at this time.
0 commit comments