Skip to content

Commit

Permalink
Auto merge of rust-lang#115871 - krasimirgg:llvm-18-en, r=durin42
Browse files Browse the repository at this point in the history
llvm-wrapper: adapt for LLVM API changes

No functional changes intended.

Adapts the wrapper for llvm/llvm-project@0a1aa6c.

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
  • Loading branch information
bors committed Sep 15, 2023
2 parents e7f9f48 + af401b0 commit 33440d7
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand Down Expand Up @@ -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.");
}
Expand Down

0 comments on commit 33440d7

Please sign in to comment.