This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +28
-1
lines changed Expand file tree Collapse file tree 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(
586586 // LTO-specific optimization passes that LLVM provides.
587587 //
588588 // 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
590590 debug ! ( "running the pass manager" ) ;
591591 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+ }
592604 if llvm_util:: should_use_new_llvm_pass_manager (
593605 & config. new_llvm_pass_manager ,
594606 & cgcx. target_arch ,
Original file line number Diff line number Diff line change @@ -326,6 +326,15 @@ pub unsafe fn create_module<'ll>(
326326 )
327327 }
328328
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+
329338 llmod
330339}
331340
Original file line number Diff line number Diff line change @@ -1936,6 +1936,7 @@ extern "C" {
19361936 name : * const c_char ,
19371937 value : u32 ,
19381938 ) ;
1939+ pub fn LLVMRustHasModuleFlag ( M : & Module , name : * const c_char , len : size_t ) -> bool ;
19391940
19401941 pub fn LLVMRustMetadataAsValue < ' a > ( C : & ' a Context , MD : & ' a Metadata ) -> & ' a Value ;
19411942
Original file line number Diff line number Diff line change @@ -672,6 +672,11 @@ extern "C" void LLVMRustAddModuleFlag(
672672 unwrap (M)->addModuleFlag (MergeBehavior, Name, Value);
673673}
674674
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+
675680extern " C" LLVMValueRef LLVMRustMetadataAsValue (LLVMContextRef C, LLVMMetadataRef MD) {
676681 return wrap (MetadataAsValue::get (*unwrap (C), unwrap (MD)));
677682}
You can’t perform that action at this time.
0 commit comments