@@ -346,8 +346,6 @@ pub(crate) unsafe fn optimize(
346346 }
347347
348348 let mut extra_passes = Vec :: new ( ) ;
349- let mut have_name_anon_globals_pass = false ;
350-
351349 for pass_name in & config. passes {
352350 if pass_name == "lint" {
353351 // Linting should also be performed early, directly on the generated IR.
@@ -360,10 +358,6 @@ pub(crate) unsafe fn optimize(
360358 } else {
361359 diag_handler. warn ( & format ! ( "unknown pass `{}`, ignoring" , pass_name) ) ;
362360 }
363-
364- if pass_name == "name-anon-globals" {
365- have_name_anon_globals_pass = true ;
366- }
367361 }
368362
369363 add_sanitizer_passes ( config, & mut extra_passes) ;
@@ -389,33 +383,17 @@ pub(crate) unsafe fn optimize(
389383 llvm:: LLVMPassManagerBuilderPopulateModulePassManager ( b, mpm) ;
390384 } ) ;
391385
392- have_name_anon_globals_pass = have_name_anon_globals_pass || prepare_for_thin_lto;
393386 if using_thin_buffers && !prepare_for_thin_lto {
394387 llvm:: LLVMRustAddPass ( mpm, find_pass ( "name-anon-globals" ) . unwrap ( ) ) ;
395- have_name_anon_globals_pass = true ;
396388 }
397389 } else {
398390 // If we don't use the standard pipeline, directly populate the MPM
399391 // with the extra passes.
400392 for pass in extra_passes {
401393 llvm:: LLVMRustAddPass ( mpm, pass) ;
402394 }
403- }
404-
405- if using_thin_buffers && !have_name_anon_globals_pass {
406- // As described above, this will probably cause an error in LLVM
407- if config. no_prepopulate_passes {
408- diag_handler. err (
409- "The current compilation is going to use thin LTO buffers \
410- without running LLVM's NameAnonGlobals pass. \
411- This will likely cause errors in LLVM. Consider adding \
412- -C passes=name-anon-globals to the compiler command line.",
413- ) ;
414- } else {
415- bug ! (
416- "We are using thin LTO buffers without running the NameAnonGlobals pass. \
417- This will likely cause errors in LLVM and should never happen."
418- ) ;
395+ if using_thin_buffers {
396+ llvm:: LLVMRustAddPass ( mpm, find_pass ( "name-anon-globals" ) . unwrap ( ) ) ;
419397 }
420398 }
421399 }
0 commit comments