From af401b0ca366edd7d0df061b7a635c06e6481f18 Mon Sep 17 00:00:00 2001 From: Krasimir Georgiev Date: Fri, 15 Sep 2023 14:31:43 +0000 Subject: [PATCH] llvm-wrapper: adapt for LLVM API changes No functional changes intended. Adapts the wrapper for https://github.com/llvm/llvm-project/commit/0a1aa6cda2758b0926a95f87d39ffefb1cb90200. Found by our experimental rust + llvm @ head CI: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/22301#018a9926-a810-4e56-8ac2-e6f30b78f433/253-551 --- .../rustc_llvm/llvm-wrapper/PassWrapper.cpp | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index fefb1e0fbe0..461b5290e69 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -239,16 +239,22 @@ enum class LLVMRustCodeGenOptLevel { Aggressive, }; -static CodeGenOpt::Level fromRust(LLVMRustCodeGenOptLevel Level) { +#if LLVM_VERSION_GE(18, 0) + using CodeGenOptLevelEnum = llvm::CodeGenOptLevel; +#else + using CodeGenOptLevelEnum = llvm::CodeGenOpt::Level; +#endif + +static CodeGenOptLevelEnum fromRust(LLVMRustCodeGenOptLevel Level) { switch (Level) { case LLVMRustCodeGenOptLevel::None: - return CodeGenOpt::None; + return CodeGenOptLevelEnum::None; case LLVMRustCodeGenOptLevel::Less: - return CodeGenOpt::Less; + return CodeGenOptLevelEnum::Less; case LLVMRustCodeGenOptLevel::Default: - return CodeGenOpt::Default; + return CodeGenOptLevelEnum::Default; case LLVMRustCodeGenOptLevel::Aggressive: - return CodeGenOpt::Aggressive; + return CodeGenOptLevelEnum::Aggressive; default: report_fatal_error("Bad CodeGenOptLevel."); } @@ -554,9 +560,17 @@ enum class LLVMRustFileType { static CodeGenFileType fromRust(LLVMRustFileType Type) { switch (Type) { case LLVMRustFileType::AssemblyFile: +#if LLVM_VERSION_GE(18, 0) + return CodeGenFileType::AssemblyFile; +#else return CGFT_AssemblyFile; +#endif case LLVMRustFileType::ObjectFile: +#if LLVM_VERSION_GE(18, 0) + return CodeGenFileType::ObjectFile; +#else return CGFT_ObjectFile; +#endif default: report_fatal_error("Bad FileType."); }