Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the minimum external LLVM to 12 #90175

Merged
merged 4 commits into from
Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update the minimum external LLVM to 12
  • Loading branch information
cuviper committed Oct 22, 2021
commit e9f545b9a952f193dbe15730bcbe47784b6e7cde
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: mingw-check
os: ubuntu-latest-xl
env: {}
- name: x86_64-gnu-llvm-11
- name: x86_64-gnu-llvm-12
os: ubuntu-latest-xl
env: {}
- name: x86_64-gnu-tools
Expand Down Expand Up @@ -274,7 +274,7 @@ jobs:
- name: x86_64-gnu-distcheck
os: ubuntu-latest-xl
env: {}
- name: x86_64-gnu-llvm-11
- name: x86_64-gnu-llvm-12
env:
RUST_BACKTRACE: 1
os: ubuntu-latest-xl
Expand Down
76 changes: 2 additions & 74 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,6 @@ void LLVMSelfProfileInitializeCallbacks(
PassInstrumentationCallbacks& PIC, void* LlvmSelfProfiler,
LLVMRustSelfProfileBeforePassCallback BeforePassCallback,
LLVMRustSelfProfileAfterPassCallback AfterPassCallback) {
#if LLVM_VERSION_GE(12, 0)
PIC.registerBeforeNonSkippedPassCallback([LlvmSelfProfiler, BeforePassCallback](
StringRef Pass, llvm::Any Ir) {
std::string PassName = Pass.str();
Expand All @@ -699,25 +698,6 @@ void LLVMSelfProfileInitializeCallbacks(
[LlvmSelfProfiler, AfterPassCallback](StringRef Pass, const PreservedAnalyses &Preserved) {
AfterPassCallback(LlvmSelfProfiler);
});
#else
PIC.registerBeforePassCallback([LlvmSelfProfiler, BeforePassCallback](
StringRef Pass, llvm::Any Ir) {
std::string PassName = Pass.str();
std::string IrName = LLVMRustwrappedIrGetName(Ir);
BeforePassCallback(LlvmSelfProfiler, PassName.c_str(), IrName.c_str());
return true;
});

PIC.registerAfterPassCallback(
[LlvmSelfProfiler, AfterPassCallback](StringRef Pass, llvm::Any Ir) {
AfterPassCallback(LlvmSelfProfiler);
});

PIC.registerAfterPassInvalidatedCallback(
[LlvmSelfProfiler, AfterPassCallback](StringRef Pass) {
AfterPassCallback(LlvmSelfProfiler);
});
#endif

PIC.registerBeforeAnalysisCallback([LlvmSelfProfiler, BeforePassCallback](
StringRef Pass, llvm::Any Ir) {
Expand Down Expand Up @@ -778,22 +758,13 @@ LLVMRustOptimizeWithNewPassManager(
PTO.LoopInterleaving = UnrollLoops;
PTO.LoopVectorization = LoopVectorize;
PTO.SLPVectorization = SLPVectorize;
#if LLVM_VERSION_GE(12, 0)
PTO.MergeFunctions = MergeFunctions;
#else
// MergeFunctions is not supported by NewPM in older LLVM versions.
(void) MergeFunctions;
#endif

// FIXME: We may want to expose this as an option.
bool DebugPassManager = false;

PassInstrumentationCallbacks PIC;
#if LLVM_VERSION_GE(12, 0)
StandardInstrumentations SI(DebugPassManager);
#else
StandardInstrumentations SI;
#endif
SI.registerCallbacks(PIC);

if (LlvmSelfProfiler){
Expand All @@ -817,18 +788,14 @@ LLVMRustOptimizeWithNewPassManager(
PGOOptions::NoCSAction, DebugInfoForProfiling);
}

#if LLVM_VERSION_GE(12, 0) && !LLVM_VERSION_GE(13,0)
PassBuilder PB(DebugPassManager, TM, PTO, PGOOpt, &PIC);
#else
PassBuilder PB(TM, PTO, PGOOpt, &PIC);
#endif

#if LLVM_VERSION_GE(13, 0)
PassBuilder PB(TM, PTO, PGOOpt, &PIC);
LoopAnalysisManager LAM;
FunctionAnalysisManager FAM;
CGSCCAnalysisManager CGAM;
ModuleAnalysisManager MAM;
#else
PassBuilder PB(DebugPassManager, TM, PTO, PGOOpt, &PIC);
LoopAnalysisManager LAM(DebugPassManager);
FunctionAnalysisManager FAM(DebugPassManager);
CGSCCAnalysisManager CGAM(DebugPassManager);
Expand Down Expand Up @@ -960,39 +927,16 @@ LLVMRustOptimizeWithNewPassManager(
// At the same time, the LTO pipelines do support O0 and using them is required.
bool IsLTO = OptStage == LLVMRustOptStage::ThinLTO || OptStage == LLVMRustOptStage::FatLTO;
if (OptLevel == OptimizationLevel::O0 && !IsLTO) {
#if LLVM_VERSION_GE(12, 0)
for (const auto &C : PipelineStartEPCallbacks)
PB.registerPipelineStartEPCallback(C);
for (const auto &C : OptimizerLastEPCallbacks)
PB.registerOptimizerLastEPCallback(C);

// Pass false as we manually schedule ThinLTOBufferPasses below.
MPM = PB.buildO0DefaultPipeline(OptLevel, /* PreLinkLTO */ false);
#else
for (const auto &C : PipelineStartEPCallbacks)
C(MPM, OptLevel);

for (const auto &C : OptimizerLastEPCallbacks)
C(MPM, OptLevel);

MPM.addPass(AlwaysInlinerPass(EmitLifetimeMarkers));

if (PGOOpt) {
PB.addPGOInstrPassesForO0(
MPM, DebugPassManager, PGOOpt->Action == PGOOptions::IRInstr,
/*IsCS=*/false, PGOOpt->ProfileFile, PGOOpt->ProfileRemappingFile);
}
#endif
} else {
#if LLVM_VERSION_GE(12, 0)
for (const auto &C : PipelineStartEPCallbacks)
PB.registerPipelineStartEPCallback(C);
#else
for (const auto &C : PipelineStartEPCallbacks)
PB.registerPipelineStartEPCallback([C, OptLevel](ModulePassManager &MPM) {
C(MPM, OptLevel);
});
#endif
if (OptStage != LLVMRustOptStage::PreLinkThinLTO) {
for (const auto &C : OptimizerLastEPCallbacks)
PB.registerOptimizerLastEPCallback(C);
Expand All @@ -1003,43 +947,27 @@ LLVMRustOptimizeWithNewPassManager(
MPM = PB.buildPerModuleDefaultPipeline(OptLevel, DebugPassManager);
break;
case LLVMRustOptStage::PreLinkThinLTO:
#if LLVM_VERSION_GE(12, 0)
MPM = PB.buildThinLTOPreLinkDefaultPipeline(OptLevel);
// The ThinLTOPreLink pipeline already includes ThinLTOBuffer passes. However, callback
// passes may still run afterwards. This means we need to run the buffer passes again.
// FIXME: In LLVM 13, the ThinLTOPreLink pipeline also runs OptimizerLastEPCallbacks
// before the RequiredLTOPreLinkPasses, in which case we can remove these hacks.
if (OptimizerLastEPCallbacks.empty())
NeedThinLTOBufferPasses = false;
#else
MPM = PB.buildThinLTOPreLinkDefaultPipeline(OptLevel, DebugPassManager);
#endif
for (const auto &C : OptimizerLastEPCallbacks)
C(MPM, OptLevel);
break;
case LLVMRustOptStage::PreLinkFatLTO:
#if LLVM_VERSION_GE(12, 0)
MPM = PB.buildLTOPreLinkDefaultPipeline(OptLevel);
NeedThinLTOBufferPasses = false;
#else
MPM = PB.buildLTOPreLinkDefaultPipeline(OptLevel, DebugPassManager);
#endif
break;
case LLVMRustOptStage::ThinLTO:
// FIXME: Does it make sense to pass the ModuleSummaryIndex?
// It only seems to be needed for C++ specific optimizations.
#if LLVM_VERSION_GE(12, 0)
MPM = PB.buildThinLTODefaultPipeline(OptLevel, nullptr);
#else
MPM = PB.buildThinLTODefaultPipeline(OptLevel, DebugPassManager, nullptr);
#endif
break;
case LLVMRustOptStage::FatLTO:
#if LLVM_VERSION_GE(12, 0)
MPM = PB.buildLTODefaultPipeline(OptLevel, nullptr);
#else
MPM = PB.buildLTODefaultPipeline(OptLevel, DebugPassManager, nullptr);
#endif
break;
}
}
Expand Down
24 changes: 0 additions & 24 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,7 @@ extern "C" void LLVMRustAddByValCallSiteAttr(LLVMValueRef Instr, unsigned Index,
extern "C" void LLVMRustAddStructRetCallSiteAttr(LLVMValueRef Instr, unsigned Index,
LLVMTypeRef Ty) {
CallBase *Call = unwrap<CallBase>(Instr);
#if LLVM_VERSION_GE(12, 0)
Attribute Attr = Attribute::getWithStructRetType(Call->getContext(), unwrap(Ty));
#else
Attribute Attr = Attribute::get(Call->getContext(), Attribute::StructRet);
#endif
AddAttribute(Call, Index, Attr);
}

Expand Down Expand Up @@ -311,11 +307,7 @@ extern "C" void LLVMRustAddByValAttr(LLVMValueRef Fn, unsigned Index,
extern "C" void LLVMRustAddStructRetAttr(LLVMValueRef Fn, unsigned Index,
LLVMTypeRef Ty) {
Function *F = unwrap<Function>(Fn);
#if LLVM_VERSION_GE(12, 0)
Attribute Attr = Attribute::getWithStructRetType(F->getContext(), unwrap(Ty));
#else
Attribute Attr = Attribute::get(F->getContext(), Attribute::StructRet);
#endif
AddAttribute(F, Index, Attr);
}

Expand Down Expand Up @@ -1024,17 +1016,11 @@ extern "C" LLVMMetadataRef
LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column,
LLVMMetadataRef ScopeRef,
LLVMMetadataRef InlinedAt) {
#if LLVM_VERSION_GE(12, 0)
MDNode *Scope = unwrapDIPtr<MDNode>(ScopeRef);
DILocation *Loc = DILocation::get(
Scope->getContext(), Line, Column, Scope,
unwrapDIPtr<MDNode>(InlinedAt));
return wrap(Loc);
#else
DebugLoc debug_loc = DebugLoc::get(Line, Column, unwrapDIPtr<MDNode>(ScopeRef),
unwrapDIPtr<MDNode>(InlinedAt));
return wrap(debug_loc.getAsMDNode());
#endif
}

extern "C" int64_t LLVMRustDIBuilderCreateOpDeref() {
Expand Down Expand Up @@ -1249,10 +1235,8 @@ extern "C" LLVMTypeKind LLVMRustGetTypeKind(LLVMTypeRef Ty) {
return LLVMScalableVectorTypeKind;
case Type::BFloatTyID:
return LLVMBFloatTypeKind;
#if LLVM_VERSION_GE(12, 0)
case Type::X86_AMXTyID:
return LLVMX86_AMXTypeKind;
#endif
}
report_fatal_error("Unhandled TypeID.");
}
Expand Down Expand Up @@ -1710,23 +1694,15 @@ LLVMRustBuildVectorReduceMax(LLVMBuilderRef B, LLVMValueRef Src, bool IsSigned)
}
extern "C" LLVMValueRef
LLVMRustBuildVectorReduceFMin(LLVMBuilderRef B, LLVMValueRef Src, bool NoNaN) {
#if LLVM_VERSION_GE(12, 0)
Instruction *I = unwrap(B)->CreateFPMinReduce(unwrap(Src));
I->setHasNoNaNs(NoNaN);
return wrap(I);
#else
return wrap(unwrap(B)->CreateFPMinReduce(unwrap(Src), NoNaN));
#endif
}
extern "C" LLVMValueRef
LLVMRustBuildVectorReduceFMax(LLVMBuilderRef B, LLVMValueRef Src, bool NoNaN) {
#if LLVM_VERSION_GE(12, 0)
Instruction *I = unwrap(B)->CreateFPMaxReduce(unwrap(Src));
I->setHasNoNaNs(NoNaN);
return wrap(I);
#else
return wrap(unwrap(B)->CreateFPMaxReduce(unwrap(Src), NoNaN));
#endif
}

extern "C" LLVMValueRef
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,11 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) {
let version = output(cmd.arg("--version"));
let mut parts = version.split('.').take(2).filter_map(|s| s.parse::<u32>().ok());
if let (Some(major), Some(_minor)) = (parts.next(), parts.next()) {
if major >= 11 {
if major >= 12 {
return;
}
}
panic!("\n\nbad LLVM version: {}, need >=11.0\n\n", version)
panic!("\n\nbad LLVM version: {}, need >=12.0\n\n", version)
}

fn configure_cmake(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
llvm-11-tools \
llvm-11-dev \
llvm-12-tools \
llvm-12-dev \
libedit-dev \
libssl-dev \
pkg-config \
Expand All @@ -29,7 +29,7 @@ RUN sh /scripts/sccache.sh
# using llvm-link-shared due to libffi issues -- see #34486
ENV RUST_CONFIGURE_ARGS \
--build=x86_64-unknown-linux-gnu \
--llvm-root=/usr/lib/llvm-11 \
--llvm-root=/usr/lib/llvm-12 \
--enable-llvm-link-shared \
--set rust.thin-lto-import-instr-limit=10

Expand Down
4 changes: 2 additions & 2 deletions src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ jobs:
- name: mingw-check
<<: *job-linux-xl

- name: x86_64-gnu-llvm-11
- name: x86_64-gnu-llvm-12
<<: *job-linux-xl

- name: x86_64-gnu-tools
Expand Down Expand Up @@ -431,7 +431,7 @@ jobs:
- name: x86_64-gnu-distcheck
<<: *job-linux-xl

- name: x86_64-gnu-llvm-11
- name: x86_64-gnu-llvm-12
env:
RUST_BACKTRACE: 1
<<: *job-linux-xl
Expand Down
1 change: 0 additions & 1 deletion src/test/assembly/asm/aarch64-outline-atomics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 12.0
// assembly-output: emit-asm
// compile-flags: -O
// compile-flags: --target aarch64-unknown-linux-gnu
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/powerpc-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// min-llvm-version: 12.0.0
// min-llvm-version: 12.0.1
// revisions: powerpc powerpc64
// assembly-output: emit-asm
//[powerpc] compile-flags: --target powerpc-unknown-linux-gnu
Expand Down
1 change: 0 additions & 1 deletion src/test/assembly/asm/riscv-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//[riscv32] compile-flags: --target riscv32imac-unknown-none-elf
//[riscv32] needs-llvm-components: riscv
// compile-flags: -C target-feature=+d
// min-system-llvm-version: 12.0

#![feature(no_core, lang_items, rustc_attrs)]
#![crate_type = "rlib"]
Expand Down
1 change: 0 additions & 1 deletion src/test/assembly/asm/wasm-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 12.0.0
// assembly-output: emit-asm
// compile-flags: --target wasm32-unknown-unknown
// compile-flags: --crate-type cdylib
Expand Down
1 change: 0 additions & 1 deletion src/test/assembly/static-relocation-model.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 12.0.0
// revisions: x64 A64 ppc64le
// assembly-output: emit-asm
// [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=static
Expand Down
2 changes: 0 additions & 2 deletions src/test/codegen/function-arguments.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// compile-flags: -O -C no-prepopulate-passes
//
// min-system-llvm-version: 12.0

#![crate_type = "lib"]
#![feature(rustc_attrs)]
Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/issue-73031.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 12.0.0
// compile-flags: -O
#![crate_type = "lib"]

Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/issue-75525-bounds-checks.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Regression test for #75525, verifies that no bounds checks are generated.

// min-llvm-version: 12.0.0
// compile-flags: -O

#![crate_type = "lib"]
Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/issue-75546.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 12.0.0
// compile-flags: -O
#![crate_type = "lib"]

Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/issue-77812.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 12.0.0
// compile-flags: -O
#![crate_type = "lib"]

Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/non-terminate/infinite-loop-1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 12.0
// compile-flags: -C opt-level=3

#![crate_type = "lib"]
Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/non-terminate/infinite-loop-2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 12.0
// compile-flags: -C opt-level=3

#![crate_type = "lib"]
Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/non-terminate/infinite-recursion.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 12.0
// compile-flags: -C opt-level=3

#![crate_type = "lib"]
Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/non-terminate/nonempty-infinite-loop.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 12.0
// compile-flags: -C opt-level=3

#![crate_type = "lib"]
Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/repr-transparent-aggregates-1.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// compile-flags: -C no-prepopulate-passes
//

// min-system-llvm-version: 12.0
// ignore-arm
// ignore-aarch64
// ignore-mips
Expand Down
Loading