Skip to content

Commit 2970ad8

Browse files
committed
Update the minimum external LLVM to 13
1 parent 801821d commit 2970ad8

34 files changed

+46
-289
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: mingw-check
4444
os: ubuntu-20.04-xl
4545
env: {}
46-
- name: x86_64-gnu-llvm-12
46+
- name: x86_64-gnu-llvm-13
4747
os: ubuntu-20.04-xl
4848
env: {}
4949
- name: x86_64-gnu-tools
@@ -274,11 +274,11 @@ jobs:
274274
- name: x86_64-gnu-distcheck
275275
os: ubuntu-20.04-xl
276276
env: {}
277-
- name: x86_64-gnu-llvm-12
277+
- name: x86_64-gnu-llvm-13
278278
env:
279279
RUST_BACKTRACE: 1
280280
os: ubuntu-20.04-xl
281-
- name: x86_64-gnu-llvm-12-stage1
281+
- name: x86_64-gnu-llvm-13-stage1
282282
env:
283283
RUST_BACKTRACE: 1
284284
os: ubuntu-20.04-xl

compiler/rustc_codegen_llvm/src/asm.rs

-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::builder::Builder;
33
use crate::common::Funclet;
44
use crate::context::CodegenCx;
55
use crate::llvm;
6-
use crate::llvm_util;
76
use crate::type_::Type;
87
use crate::type_of::LayoutLlvmExt;
98
use crate::value::Value;
@@ -419,13 +418,6 @@ pub(crate) fn inline_asm_call<'ll>(
419418
let constraints_ok = llvm::LLVMRustInlineAsmVerify(fty, cons.as_ptr().cast(), cons.len());
420419
debug!("constraint verification result: {:?}", constraints_ok);
421420
if constraints_ok {
422-
if unwind && llvm_util::get_version() < (13, 0, 0) {
423-
bx.cx.sess().span_fatal(
424-
line_spans[0],
425-
"unwinding from inline assembly is only supported on llvm >= 13.",
426-
);
427-
}
428-
429421
let v = llvm::LLVMRustInlineAsm(
430422
fty,
431423
asm.as_ptr().cast(),

compiler/rustc_codegen_llvm/src/back/write.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::back::profiling::{
55
use crate::base;
66
use crate::common;
77
use crate::consts;
8-
use crate::llvm::{self, DiagnosticInfo, PassManager, SMDiagnostic};
8+
use crate::llvm::{self, DiagnosticInfo, PassManager};
99
use crate::llvm_util;
1010
use crate::type_::Type;
1111
use crate::LlvmCodegenBackend;
@@ -304,17 +304,14 @@ impl<'a> DiagnosticHandlers<'a> {
304304
remark_passes.as_ptr(),
305305
remark_passes.len(),
306306
);
307-
llvm::LLVMRustSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, data.cast());
308307
DiagnosticHandlers { data, llcx, old_handler }
309308
}
310309
}
311310
}
312311

313312
impl<'a> Drop for DiagnosticHandlers<'a> {
314313
fn drop(&mut self) {
315-
use std::ptr::null_mut;
316314
unsafe {
317-
llvm::LLVMRustSetInlineAsmDiagnosticHandler(self.llcx, inline_asm_handler, null_mut());
318315
llvm::LLVMRustContextSetDiagnosticHandler(self.llcx, self.old_handler);
319316
drop(Box::from_raw(self.data));
320317
}
@@ -342,16 +339,6 @@ fn report_inline_asm(
342339
cgcx.diag_emitter.inline_asm_error(cookie as u32, msg, level, source);
343340
}
344341

345-
unsafe extern "C" fn inline_asm_handler(diag: &SMDiagnostic, user: *const c_void, cookie: c_uint) {
346-
if user.is_null() {
347-
return;
348-
}
349-
let (cgcx, _) = *(user as *const (&CodegenContext<LlvmCodegenBackend>, &Handler));
350-
351-
let smdiag = llvm::diagnostic::SrcMgrDiagnostic::unpack(diag);
352-
report_inline_asm(cgcx, smdiag.message, smdiag.level, cookie, smdiag.source);
353-
}
354-
355342
unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void) {
356343
if user.is_null() {
357344
return;

compiler/rustc_codegen_llvm/src/builder.rs

+25-54
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::common::Funclet;
33
use crate::context::CodegenCx;
44
use crate::llvm::{self, BasicBlock, False};
55
use crate::llvm::{AtomicOrdering, AtomicRmwBinOp, SynchronizationScope};
6-
use crate::llvm_util;
76
use crate::type_::Type;
87
use crate::type_of::LayoutLlvmExt;
98
use crate::value::Value;
@@ -1038,25 +1037,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
10381037
dst: &'ll Value,
10391038
cmp: &'ll Value,
10401039
src: &'ll Value,
1041-
mut order: rustc_codegen_ssa::common::AtomicOrdering,
1040+
order: rustc_codegen_ssa::common::AtomicOrdering,
10421041
failure_order: rustc_codegen_ssa::common::AtomicOrdering,
10431042
weak: bool,
10441043
) -> &'ll Value {
10451044
let weak = if weak { llvm::True } else { llvm::False };
1046-
if llvm_util::get_version() < (13, 0, 0) {
1047-
use rustc_codegen_ssa::common::AtomicOrdering::*;
1048-
// Older llvm has the pre-C++17 restriction on
1049-
// success and failure memory ordering,
1050-
// requiring the former to be at least as strong as the latter.
1051-
// So, for llvm 12, we upgrade the success ordering to a stronger
1052-
// one if necessary.
1053-
match (order, failure_order) {
1054-
(Relaxed, Acquire) => order = Acquire,
1055-
(Release, Acquire) => order = AcquireRelease,
1056-
(_, SequentiallyConsistent) => order = SequentiallyConsistent,
1057-
_ => {}
1058-
}
1059-
}
10601045
unsafe {
10611046
llvm::LLVMRustBuildAtomicCmpXchg(
10621047
self.llbuilder,
@@ -1444,51 +1429,37 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
14441429
}
14451430
}
14461431

1447-
fn fptoint_sat_broken_in_llvm(&self) -> bool {
1448-
match self.tcx.sess.target.arch.as_ref() {
1449-
// FIXME - https://bugs.llvm.org/show_bug.cgi?id=50083
1450-
"riscv64" => llvm_util::get_version() < (13, 0, 0),
1451-
_ => false,
1452-
}
1453-
}
1454-
14551432
fn fptoint_sat(
14561433
&mut self,
14571434
signed: bool,
14581435
val: &'ll Value,
14591436
dest_ty: &'ll Type,
14601437
) -> Option<&'ll Value> {
1461-
if !self.fptoint_sat_broken_in_llvm() {
1462-
let src_ty = self.cx.val_ty(val);
1463-
let (float_ty, int_ty, vector_length) = if self.cx.type_kind(src_ty) == TypeKind::Vector
1464-
{
1465-
assert_eq!(self.cx.vector_length(src_ty), self.cx.vector_length(dest_ty));
1466-
(
1467-
self.cx.element_type(src_ty),
1468-
self.cx.element_type(dest_ty),
1469-
Some(self.cx.vector_length(src_ty)),
1470-
)
1471-
} else {
1472-
(src_ty, dest_ty, None)
1473-
};
1474-
let float_width = self.cx.float_width(float_ty);
1475-
let int_width = self.cx.int_width(int_ty);
1476-
1477-
let instr = if signed { "fptosi" } else { "fptoui" };
1478-
let name = if let Some(vector_length) = vector_length {
1479-
format!(
1480-
"llvm.{}.sat.v{}i{}.v{}f{}",
1481-
instr, vector_length, int_width, vector_length, float_width
1482-
)
1483-
} else {
1484-
format!("llvm.{}.sat.i{}.f{}", instr, int_width, float_width)
1485-
};
1486-
let f =
1487-
self.declare_cfn(&name, llvm::UnnamedAddr::No, self.type_func(&[src_ty], dest_ty));
1488-
Some(self.call(self.type_func(&[src_ty], dest_ty), f, &[val], None))
1438+
let src_ty = self.cx.val_ty(val);
1439+
let (float_ty, int_ty, vector_length) = if self.cx.type_kind(src_ty) == TypeKind::Vector {
1440+
assert_eq!(self.cx.vector_length(src_ty), self.cx.vector_length(dest_ty));
1441+
(
1442+
self.cx.element_type(src_ty),
1443+
self.cx.element_type(dest_ty),
1444+
Some(self.cx.vector_length(src_ty)),
1445+
)
14891446
} else {
1490-
None
1491-
}
1447+
(src_ty, dest_ty, None)
1448+
};
1449+
let float_width = self.cx.float_width(float_ty);
1450+
let int_width = self.cx.int_width(int_ty);
1451+
1452+
let instr = if signed { "fptosi" } else { "fptoui" };
1453+
let name = if let Some(vector_length) = vector_length {
1454+
format!(
1455+
"llvm.{}.sat.v{}i{}.v{}f{}",
1456+
instr, vector_length, int_width, vector_length, float_width
1457+
)
1458+
} else {
1459+
format!("llvm.{}.sat.i{}.f{}", instr, int_width, float_width)
1460+
};
1461+
let f = self.declare_cfn(&name, llvm::UnnamedAddr::No, self.type_func(&[src_ty], dest_ty));
1462+
Some(self.call(self.type_func(&[src_ty], dest_ty), f, &[val], None))
14921463
}
14931464

14941465
pub(crate) fn landing_pad(

compiler/rustc_codegen_llvm/src/context.rs

-11
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,6 @@ pub unsafe fn create_module<'ll>(
142142

143143
let mut target_data_layout = sess.target.data_layout.to_string();
144144
let llvm_version = llvm_util::get_version();
145-
if llvm_version < (13, 0, 0) {
146-
if sess.target.arch == "powerpc64" {
147-
target_data_layout = target_data_layout.replace("-S128", "");
148-
}
149-
if sess.target.arch == "wasm32" {
150-
target_data_layout = "e-m:e-p:32:32-i64:64-n32:64-S128".to_string();
151-
}
152-
if sess.target.arch == "wasm64" {
153-
target_data_layout = "e-m:e-p:64:64-i64:64-n32:64-S128".to_string();
154-
}
155-
}
156145
if llvm_version < (14, 0, 0) {
157146
if sess.target.llvm_target == "i686-pc-windows-msvc"
158147
|| sess.target.llvm_target == "i586-pc-windows-msvc"

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

-6
Original file line numberDiff line numberDiff line change
@@ -2410,12 +2410,6 @@ extern "C" {
24102410
cookie_out: &mut c_uint,
24112411
) -> &'a SMDiagnostic;
24122412

2413-
pub fn LLVMRustSetInlineAsmDiagnosticHandler(
2414-
C: &Context,
2415-
H: InlineAsmDiagHandlerTy,
2416-
CX: *mut c_void,
2417-
);
2418-
24192413
#[allow(improper_ctypes)]
24202414
pub fn LLVMRustUnpackSMDiagnostic(
24212415
d: &SMDiagnostic,

compiler/rustc_codegen_llvm/src/llvm_util.rs

-10
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,6 @@ unsafe fn configure_llvm(sess: &Session) {
9292
add("-generate-arange-section", false);
9393
}
9494

95-
// Disable the machine outliner by default in LLVM versions 11 and LLVM
96-
// version 12, where it leads to miscompilation.
97-
//
98-
// Ref:
99-
// - https://github.com/rust-lang/rust/issues/85351
100-
// - https://reviews.llvm.org/D103167
101-
if llvm_util::get_version() < (13, 0, 0) {
102-
add("-enable-machine-outliner=never", false);
103-
}
104-
10595
match sess.opts.unstable_opts.merge_functions.unwrap_or(sess.target.merge_functions) {
10696
MergeFunctions::Disabled | MergeFunctions::Trampolines => {}
10797
MergeFunctions::Aliases => {

compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,10 @@ extern "C" void LLVMRustCoverageWriteFilenamesSectionToBuffer(
2424
const char* const Filenames[],
2525
size_t FilenamesLen,
2626
RustStringRef BufferOut) {
27-
#if LLVM_VERSION_GE(13,0)
2827
SmallVector<std::string,32> FilenameRefs;
2928
for (size_t i = 0; i < FilenamesLen; i++) {
3029
FilenameRefs.push_back(std::string(Filenames[i]));
3130
}
32-
#else
33-
SmallVector<StringRef,32> FilenameRefs;
34-
for (size_t i = 0; i < FilenamesLen; i++) {
35-
FilenameRefs.push_back(StringRef(Filenames[i]));
36-
}
37-
#endif
3831
auto FilenamesWriter = coverage::CoverageFilenamesSectionWriter(
3932
makeArrayRef(FilenameRefs));
4033
RawRustStringOstream OS(BufferOut);
@@ -109,9 +102,5 @@ extern "C" void LLVMRustCoverageWriteMappingVarNameToString(RustStringRef Str) {
109102
}
110103

111104
extern "C" uint32_t LLVMRustCoverageMappingVersion() {
112-
#if LLVM_VERSION_GE(13, 0)
113105
return coverage::CovMapVersion::Version6;
114-
#else
115-
return coverage::CovMapVersion::Version5;
116-
#endif
117106
}

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+1-17
Original file line numberDiff line numberDiff line change
@@ -869,19 +869,11 @@ LLVMRustOptimizeWithNewPassManager(
869869
PGOOptions::NoCSAction, DebugInfoForProfiling);
870870
}
871871

872-
#if LLVM_VERSION_GE(13, 0)
873872
PassBuilder PB(TM, PTO, PGOOpt, &PIC);
874873
LoopAnalysisManager LAM;
875874
FunctionAnalysisManager FAM;
876875
CGSCCAnalysisManager CGAM;
877876
ModuleAnalysisManager MAM;
878-
#else
879-
PassBuilder PB(DebugPassManager, TM, PTO, PGOOpt, &PIC);
880-
LoopAnalysisManager LAM(DebugPassManager);
881-
FunctionAnalysisManager FAM(DebugPassManager);
882-
CGSCCAnalysisManager CGAM(DebugPassManager);
883-
ModuleAnalysisManager MAM(DebugPassManager);
884-
#endif
885877

886878
FAM.registerPass([&] { return PB.buildDefaultAAPipeline(); });
887879

@@ -1015,11 +1007,7 @@ LLVMRustOptimizeWithNewPassManager(
10151007
}
10161008
}
10171009

1018-
#if LLVM_VERSION_GE(13, 0)
10191010
ModulePassManager MPM;
1020-
#else
1021-
ModulePassManager MPM(DebugPassManager);
1022-
#endif
10231011
bool NeedThinLTOBufferPasses = UseThinLTOBuffers;
10241012
if (!NoPrepopulatePasses) {
10251013
// The pre-link pipelines don't support O0 and require using budilO0DefaultPipeline() instead.
@@ -1434,17 +1422,13 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
14341422
Ret->ResolvedODR[ModuleIdentifier][GUID] = NewLinkage;
14351423
};
14361424

1437-
#if LLVM_VERSION_GE(13,0)
14381425
// Uses FromPrevailing visibility scheme which works for many binary
14391426
// formats. We probably could and should use ELF visibility scheme for many of
14401427
// our targets, however.
14411428
lto::Config conf;
14421429
thinLTOResolvePrevailingInIndex(conf, Ret->Index, isPrevailing, recordNewLinkage,
14431430
Ret->GUIDPreservedSymbols);
1444-
#else
1445-
thinLTOResolvePrevailingInIndex(Ret->Index, isPrevailing, recordNewLinkage,
1446-
Ret->GUIDPreservedSymbols);
1447-
#endif
1431+
14481432
// Here we calculate an `ExportedGUIDs` set for use in the `isExported`
14491433
// callback below. This callback below will dictate the linkage for all
14501434
// summaries in the index, and we basically just only want to ensure that dead

0 commit comments

Comments
 (0)