diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index e77d63d91703b..1bd5094c38f02 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -1165,7 +1165,9 @@ extern "C" LLVMRustResult LLVMRustPrintModule(LLVMModuleRef M, const char *Path, LLVMRustSetLastError(ErrorInfo.c_str()); return LLVMRustResult::Failure; } - +#if LLVM_VERSION_GE(24, 0) + unwrap(M)->renumberMetadataForAssembly(); +#endif auto AAW = RustAssemblyAnnotationWriter(Demangle); auto FOS = formatted_raw_ostream(OS); unwrap(M)->print(FOS, &AAW);