Skip to content

Commit 6e17a5c

Browse files
committed
Auto merge of #83387 - cuviper:min-llvm-10, r=nagisa
Update the minimum external LLVM to 10 r? `@nikic`
2 parents bba4088 + fcb37cb commit 6e17a5c

File tree

16 files changed

+19
-137
lines changed

16 files changed

+19
-137
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: mingw-check
4444
os: ubuntu-latest-xl
4545
env: {}
46-
- name: x86_64-gnu-llvm-9
46+
- name: x86_64-gnu-llvm-10
4747
os: ubuntu-latest-xl
4848
env: {}
4949
- name: x86_64-gnu-tools
@@ -265,7 +265,7 @@ jobs:
265265
- name: x86_64-gnu-distcheck
266266
os: ubuntu-latest-xl
267267
env: {}
268-
- name: x86_64-gnu-llvm-9
268+
- name: x86_64-gnu-llvm-10
269269
env:
270270
RUST_BACKTRACE: 1
271271
os: ubuntu-latest-xl

compiler/rustc_codegen_llvm/src/context.rs

-9
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ fn to_llvm_tls_model(tls_model: TlsModel) -> llvm::ThreadLocalMode {
101101
}
102102
}
103103

104-
fn strip_x86_address_spaces(data_layout: String) -> String {
105-
data_layout.replace("-p270:32:32-p271:32:32-p272:64:64-", "-")
106-
}
107-
108104
fn strip_powerpc64_vectors(data_layout: String) -> String {
109105
data_layout.replace("-v256:256:256-v512:512:512", "")
110106
}
@@ -119,11 +115,6 @@ pub unsafe fn create_module(
119115
let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx);
120116

121117
let mut target_data_layout = sess.target.data_layout.clone();
122-
if llvm_util::get_version() < (10, 0, 0)
123-
&& (sess.target.arch == "x86" || sess.target.arch == "x86_64")
124-
{
125-
target_data_layout = strip_x86_address_spaces(target_data_layout);
126-
}
127118
if llvm_util::get_version() < (12, 0, 0) && sess.target.arch == "powerpc64" {
128119
target_data_layout = strip_powerpc64_vectors(target_data_layout);
129120
}

compiler/rustc_llvm/build.rs

-14
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,6 @@ fn main() {
8888
"riscv",
8989
];
9090

91-
let mut version_cmd = Command::new(&llvm_config);
92-
version_cmd.arg("--version");
93-
let version_output = output(&mut version_cmd);
94-
let mut parts = version_output.split('.').take(2).filter_map(|s| s.parse::<u32>().ok());
95-
let (major, _minor) = if let (Some(major), Some(minor)) = (parts.next(), parts.next()) {
96-
(major, minor)
97-
} else {
98-
(8, 0)
99-
};
100-
10191
let required_components = &[
10292
"ipo",
10393
"bitreader",
@@ -123,10 +113,6 @@ fn main() {
123113
println!("cargo:rustc-cfg=llvm_component=\"{}\"", component);
124114
}
125115

126-
if major >= 9 {
127-
println!("cargo:rustc-cfg=llvm_has_msp430_asm_parser");
128-
}
129-
130116
// Link in our own LLVM shims, compiled with the same flags as LLVM
131117
let mut cmd = Command::new(&llvm_config);
132118
cmd.arg("--cxxflags");

compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,7 @@ extern "C" void LLVMRustDestroyArchive(LLVMRustArchiveRef RustArchive) {
9191
extern "C" LLVMRustArchiveIteratorRef
9292
LLVMRustArchiveIteratorNew(LLVMRustArchiveRef RustArchive) {
9393
Archive *Archive = RustArchive->getBinary();
94-
#if LLVM_VERSION_GE(10, 0)
9594
std::unique_ptr<Error> Err = std::make_unique<Error>(Error::success());
96-
#else
97-
std::unique_ptr<Error> Err = llvm::make_unique<Error>(Error::success());
98-
#endif
9995
auto Cur = Archive->child_begin(*Err);
10096
if (*Err) {
10197
LLVMRustSetLastError(toString(std::move(*Err)).c_str());

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

-41
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,9 @@ extern "C" void LLVMInitializePasses() {
6565
}
6666

6767
extern "C" void LLVMTimeTraceProfilerInitialize() {
68-
#if LLVM_VERSION_GE(10, 0)
6968
timeTraceProfilerInitialize(
7069
/* TimeTraceGranularity */ 0,
7170
/* ProcName */ "rustc");
72-
#else
73-
timeTraceProfilerInitialize();
74-
#endif
7571
}
7672

7773
extern "C" void LLVMTimeTraceProfilerFinish(const char* FileName) {
@@ -596,7 +592,6 @@ enum class LLVMRustFileType {
596592
ObjectFile,
597593
};
598594

599-
#if LLVM_VERSION_GE(10, 0)
600595
static CodeGenFileType fromRust(LLVMRustFileType Type) {
601596
switch (Type) {
602597
case LLVMRustFileType::AssemblyFile:
@@ -607,18 +602,6 @@ static CodeGenFileType fromRust(LLVMRustFileType Type) {
607602
report_fatal_error("Bad FileType.");
608603
}
609604
}
610-
#else
611-
static TargetMachine::CodeGenFileType fromRust(LLVMRustFileType Type) {
612-
switch (Type) {
613-
case LLVMRustFileType::AssemblyFile:
614-
return TargetMachine::CGFT_AssemblyFile;
615-
case LLVMRustFileType::ObjectFile:
616-
return TargetMachine::CGFT_ObjectFile;
617-
default:
618-
report_fatal_error("Bad FileType.");
619-
}
620-
}
621-
#endif
622605

623606
extern "C" LLVMRustResult
624607
LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR,
@@ -868,13 +851,11 @@ LLVMRustOptimizeWithNewPassManager(
868851
}
869852
);
870853
#else
871-
#if LLVM_VERSION_GE(10, 0)
872854
PipelineStartEPCallbacks.push_back(
873855
[Options](ModulePassManager &MPM, PassBuilder::OptimizationLevel Level) {
874856
MPM.addPass(MemorySanitizerPass(Options));
875857
}
876858
);
877-
#endif
878859
OptimizerLastEPCallbacks.push_back(
879860
[Options](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) {
880861
FPM.addPass(MemorySanitizerPass(Options));
@@ -892,13 +873,11 @@ LLVMRustOptimizeWithNewPassManager(
892873
}
893874
);
894875
#else
895-
#if LLVM_VERSION_GE(10, 0)
896876
PipelineStartEPCallbacks.push_back(
897877
[](ModulePassManager &MPM, PassBuilder::OptimizationLevel Level) {
898878
MPM.addPass(ThreadSanitizerPass());
899879
}
900880
);
901-
#endif
902881
OptimizerLastEPCallbacks.push_back(
903882
[](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) {
904883
FPM.addPass(ThreadSanitizerPass());
@@ -989,13 +968,11 @@ LLVMRustOptimizeWithNewPassManager(
989968

990969
MPM.addPass(AlwaysInlinerPass(EmitLifetimeMarkers));
991970

992-
# if LLVM_VERSION_GE(10, 0)
993971
if (PGOOpt) {
994972
PB.addPGOInstrPassesForO0(
995973
MPM, DebugPassManager, PGOOpt->Action == PGOOptions::IRInstr,
996974
/*IsCS=*/false, PGOOpt->ProfileFile, PGOOpt->ProfileRemappingFile);
997975
}
998-
# endif
999976
#endif
1000977
} else {
1001978
#if LLVM_VERSION_GE(12, 0)
@@ -1366,11 +1343,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
13661343
int num_modules,
13671344
const char **preserved_symbols,
13681345
int num_symbols) {
1369-
#if LLVM_VERSION_GE(10, 0)
13701346
auto Ret = std::make_unique<LLVMRustThinLTOData>();
1371-
#else
1372-
auto Ret = llvm::make_unique<LLVMRustThinLTOData>();
1373-
#endif
13741347

13751348
// Load each module's summary and merge it into one combined index
13761349
for (int i = 0; i < num_modules; i++) {
@@ -1463,23 +1436,13 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
14631436
ExportedGUIDs.insert(GUID);
14641437
}
14651438
}
1466-
#if LLVM_VERSION_GE(10, 0)
14671439
auto isExported = [&](StringRef ModuleIdentifier, ValueInfo VI) {
14681440
const auto &ExportList = Ret->ExportLists.find(ModuleIdentifier);
14691441
return (ExportList != Ret->ExportLists.end() &&
14701442
ExportList->second.count(VI)) ||
14711443
ExportedGUIDs.count(VI.getGUID());
14721444
};
14731445
thinLTOInternalizeAndPromoteInIndex(Ret->Index, isExported, isPrevailing);
1474-
#else
1475-
auto isExported = [&](StringRef ModuleIdentifier, GlobalValue::GUID GUID) {
1476-
const auto &ExportList = Ret->ExportLists.find(ModuleIdentifier);
1477-
return (ExportList != Ret->ExportLists.end() &&
1478-
ExportList->second.count(GUID)) ||
1479-
ExportedGUIDs.count(GUID);
1480-
};
1481-
thinLTOInternalizeAndPromoteInIndex(Ret->Index, isExported);
1482-
#endif
14831446

14841447
return Ret.release();
14851448
}
@@ -1636,11 +1599,7 @@ struct LLVMRustThinLTOBuffer {
16361599

16371600
extern "C" LLVMRustThinLTOBuffer*
16381601
LLVMRustThinLTOBufferCreate(LLVMModuleRef M) {
1639-
#if LLVM_VERSION_GE(10, 0)
16401602
auto Ret = std::make_unique<LLVMRustThinLTOBuffer>();
1641-
#else
1642-
auto Ret = llvm::make_unique<LLVMRustThinLTOBuffer>();
1643-
#endif
16441603
{
16451604
raw_string_ostream OS(Ret->data);
16461605
{

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

-38
Original file line numberDiff line numberDiff line change
@@ -541,11 +541,6 @@ static DINode::DIFlags fromRust(LLVMRustDIFlags Flags) {
541541
if (isSet(Flags & LLVMRustDIFlags::FlagAppleBlock)) {
542542
Result |= DINode::DIFlags::FlagAppleBlock;
543543
}
544-
#if LLVM_VERSION_LT(10, 0)
545-
if (isSet(Flags & LLVMRustDIFlags::FlagBlockByrefStruct)) {
546-
Result |= DINode::DIFlags::FlagBlockByrefStruct;
547-
}
548-
#endif
549544
if (isSet(Flags & LLVMRustDIFlags::FlagVirtual)) {
550545
Result |= DINode::DIFlags::FlagVirtual;
551546
}
@@ -910,9 +905,7 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticVariable(
910905
unwrapDI<DIDescriptor>(Context), StringRef(Name, NameLen),
911906
StringRef(LinkageName, LinkageNameLen),
912907
unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), IsLocalToUnit,
913-
#if LLVM_VERSION_GE(10, 0)
914908
/* isDefined */ true,
915-
#endif
916909
InitExpr, unwrapDIPtr<MDNode>(Decl),
917910
/* templateParams */ nullptr,
918911
AlignInBits);
@@ -1099,19 +1092,11 @@ inline section_iterator *unwrap(LLVMSectionIteratorRef SI) {
10991092

11001093
extern "C" size_t LLVMRustGetSectionName(LLVMSectionIteratorRef SI,
11011094
const char **Ptr) {
1102-
#if LLVM_VERSION_GE(10, 0)
11031095
auto NameOrErr = (*unwrap(SI))->getName();
11041096
if (!NameOrErr)
11051097
report_fatal_error(NameOrErr.takeError());
11061098
*Ptr = NameOrErr->data();
11071099
return NameOrErr->size();
1108-
#else
1109-
StringRef Ret;
1110-
if (std::error_code EC = (*unwrap(SI))->getName(Ret))
1111-
report_fatal_error(EC.message());
1112-
*Ptr = Ret.data();
1113-
return Ret.size();
1114-
#endif
11151100
}
11161101

11171102
// LLVMArrayType function does not support 64-bit ElementCount
@@ -1450,47 +1435,28 @@ extern "C" LLVMValueRef LLVMRustBuildMemCpy(LLVMBuilderRef B,
14501435
LLVMValueRef Dst, unsigned DstAlign,
14511436
LLVMValueRef Src, unsigned SrcAlign,
14521437
LLVMValueRef Size, bool IsVolatile) {
1453-
#if LLVM_VERSION_GE(10, 0)
14541438
return wrap(unwrap(B)->CreateMemCpy(
14551439
unwrap(Dst), MaybeAlign(DstAlign),
14561440
unwrap(Src), MaybeAlign(SrcAlign),
14571441
unwrap(Size), IsVolatile));
1458-
#else
1459-
return wrap(unwrap(B)->CreateMemCpy(
1460-
unwrap(Dst), DstAlign,
1461-
unwrap(Src), SrcAlign,
1462-
unwrap(Size), IsVolatile));
1463-
#endif
14641442
}
14651443

14661444
extern "C" LLVMValueRef LLVMRustBuildMemMove(LLVMBuilderRef B,
14671445
LLVMValueRef Dst, unsigned DstAlign,
14681446
LLVMValueRef Src, unsigned SrcAlign,
14691447
LLVMValueRef Size, bool IsVolatile) {
1470-
#if LLVM_VERSION_GE(10, 0)
14711448
return wrap(unwrap(B)->CreateMemMove(
14721449
unwrap(Dst), MaybeAlign(DstAlign),
14731450
unwrap(Src), MaybeAlign(SrcAlign),
14741451
unwrap(Size), IsVolatile));
1475-
#else
1476-
return wrap(unwrap(B)->CreateMemMove(
1477-
unwrap(Dst), DstAlign,
1478-
unwrap(Src), SrcAlign,
1479-
unwrap(Size), IsVolatile));
1480-
#endif
14811452
}
14821453

14831454
extern "C" LLVMValueRef LLVMRustBuildMemSet(LLVMBuilderRef B,
14841455
LLVMValueRef Dst, unsigned DstAlign,
14851456
LLVMValueRef Val,
14861457
LLVMValueRef Size, bool IsVolatile) {
1487-
#if LLVM_VERSION_GE(10, 0)
14881458
return wrap(unwrap(B)->CreateMemSet(
14891459
unwrap(Dst), unwrap(Val), unwrap(Size), MaybeAlign(DstAlign), IsVolatile));
1490-
#else
1491-
return wrap(unwrap(B)->CreateMemSet(
1492-
unwrap(Dst), unwrap(Val), unwrap(Size), DstAlign, IsVolatile));
1493-
#endif
14941460
}
14951461

14961462
extern "C" LLVMValueRef
@@ -1676,11 +1642,7 @@ struct LLVMRustModuleBuffer {
16761642

16771643
extern "C" LLVMRustModuleBuffer*
16781644
LLVMRustModuleBufferCreate(LLVMModuleRef M) {
1679-
#if LLVM_VERSION_GE(10, 0)
16801645
auto Ret = std::make_unique<LLVMRustModuleBuffer>();
1681-
#else
1682-
auto Ret = llvm::make_unique<LLVMRustModuleBuffer>();
1683-
#endif
16841646
{
16851647
raw_string_ostream OS(Ret->data);
16861648
{

compiler/rustc_llvm/src/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,7 @@ pub fn initialize_available_targets() {
125125
LLVMInitializeMSP430TargetInfo,
126126
LLVMInitializeMSP430Target,
127127
LLVMInitializeMSP430TargetMC,
128-
LLVMInitializeMSP430AsmPrinter
129-
);
130-
init_target!(
131-
all(llvm_component = "msp430", llvm_has_msp430_asm_parser),
128+
LLVMInitializeMSP430AsmPrinter,
132129
LLVMInitializeMSP430AsmParser
133130
);
134131
init_target!(

library/core/src/num/dec2flt/algorithm.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ mod fpu_precision {
6262
// any `u16`
6363
unsafe {
6464
asm!(
65-
"fldcw ({})",
65+
"fldcw word ptr [{}]",
6666
in(reg) &cw,
67-
// FIXME: We are using ATT syntax to support LLVM 8 and LLVM 9.
68-
options(att_syntax, nostack),
67+
options(nostack),
6968
)
7069
}
7170
}
@@ -87,10 +86,9 @@ mod fpu_precision {
8786
// any `u16`
8887
unsafe {
8988
asm!(
90-
"fnstcw ({})",
89+
"fnstcw word ptr [{}]",
9190
in(reg) &mut cw,
92-
// FIXME: We are using ATT syntax to support LLVM 8 and LLVM 9.
93-
options(att_syntax, nostack),
91+
options(nostack),
9492
)
9593
}
9694

library/profiler_builtins/build.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@ fn main() {
2424
"InstrProfilingPlatformLinux.c",
2525
"InstrProfilingPlatformOther.c",
2626
"InstrProfilingPlatformWindows.c",
27+
"InstrProfilingRuntime.cpp",
2728
"InstrProfilingUtil.c",
2829
"InstrProfilingValue.c",
2930
"InstrProfilingVersionVar.c",
3031
"InstrProfilingWriter.c",
31-
// This file was renamed in LLVM 10.
32-
"InstrProfilingRuntime.cc",
33-
"InstrProfilingRuntime.cpp",
3432
// These files were added in LLVM 11.
3533
"InstrProfilingInternal.c",
3634
"InstrProfilingBiasVar.c",

library/std/src/sys/sgx/abi/mem.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ pub fn image_base() -> u64 {
3636
let base: u64;
3737
unsafe {
3838
asm!(
39-
"lea IMAGE_BASE(%rip), {}",
39+
"lea {}, qword ptr [rip + IMAGE_BASE]",
4040
lateout(reg) base,
41-
// NOTE(#76738): ATT syntax is used to support LLVM 8 and 9.
42-
options(att_syntax, nostack, preserves_flags, nomem, pure),
41+
options(nostack, preserves_flags, nomem, pure),
4342
)
4443
};
4544
base

library/std/src/sys/sgx/ext/arch.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ pub fn egetkey(request: &Align512<[u8; 512]>) -> Result<Align16<[u8; 16]>, u32>
3636
inlateout("eax") ENCLU_EGETKEY => error,
3737
in("rbx") request,
3838
in("rcx") out.as_mut_ptr(),
39-
// NOTE(#76738): ATT syntax is used to support LLVM 8 and 9.
40-
options(att_syntax, nostack),
39+
options(nostack),
4140
);
4241

4342
match error {
@@ -66,8 +65,7 @@ pub fn ereport(
6665
in("rbx") targetinfo,
6766
in("rcx") reportdata,
6867
in("rdx") report.as_mut_ptr(),
69-
// NOTE(#76738): ATT syntax is used to support LLVM 8 and 9.
70-
options(att_syntax, preserves_flags, nostack),
68+
options(preserves_flags, nostack),
7169
);
7270

7371
report.assume_init()

0 commit comments

Comments
 (0)