Skip to content

Commit ae7020f

Browse files
authoredNov 15, 2020
Rollup merge of #78848 - DevJPM:ci-llvm-9, r=nikic
Bump minimal supported LLVM version to 9 This bumps the minimal tested llvm version to 9. This should enable supporting newer LLVM features (and CPU extensions). This was motived by #78361 having to drop features because of LLVM 8 not supporting certain CPU extensions yet. This was declared relatively uncontroversial on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Min.20Supported.20LLVM.20Upgrade.20Process.3F/near/215957859). Paging ````@eddyb```` because there was a comment in the [dockerfile](https://github.com/rust-lang/rust/blob/master/src/ci/docker/host-x86_64/x86_64-gnu-llvm-8/Dockerfile#L42) describing a hack (which I don't quite understand) which was also blocked by not having LLVM 9.
2 parents dbb37fb + 86193ca commit ae7020f

File tree

13 files changed

+15
-100
lines changed

13 files changed

+15
-100
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-8
46+
- name: x86_64-gnu-llvm-9
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-8
268+
- name: x86_64-gnu-llvm-9
269269
env:
270270
RUST_BACKTRACE: 1
271271
os: ubuntu-latest-xl

‎compiler/rustc_codegen_llvm/src/attributes.rs

+1-25
Original file line numberDiff line numberDiff line change
@@ -144,25 +144,6 @@ fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
144144
);
145145
}
146146

147-
fn translate_obsolete_target_features(feature: &str) -> &str {
148-
const LLVM9_FEATURE_CHANGES: &[(&str, &str)] =
149-
&[("+fp-only-sp", "-fp64"), ("-fp-only-sp", "+fp64"), ("+d16", "-d32"), ("-d16", "+d32")];
150-
if llvm_util::get_major_version() >= 9 {
151-
for &(old, new) in LLVM9_FEATURE_CHANGES {
152-
if feature == old {
153-
return new;
154-
}
155-
}
156-
} else {
157-
for &(old, new) in LLVM9_FEATURE_CHANGES {
158-
if feature == new {
159-
return old;
160-
}
161-
}
162-
}
163-
feature
164-
}
165-
166147
pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
167148
const RUSTC_SPECIFIC_FEATURES: &[&str] = &["crt-static"];
168149

@@ -172,12 +153,7 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
172153
.target_feature
173154
.split(',')
174155
.filter(|f| !RUSTC_SPECIFIC_FEATURES.iter().any(|s| f.contains(s)));
175-
sess.target
176-
.features
177-
.split(',')
178-
.chain(cmdline)
179-
.filter(|l| !l.is_empty())
180-
.map(translate_obsolete_target_features)
156+
sess.target.features.split(',').chain(cmdline).filter(|l| !l.is_empty())
181157
}
182158

183159
pub fn apply_target_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {

‎compiler/rustc_codegen_llvm/src/back/write.rs

-5
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,6 @@ fn get_pgo_use_path(config: &ModuleConfig) -> Option<CString> {
377377
}
378378

379379
pub(crate) fn should_use_new_llvm_pass_manager(config: &ModuleConfig) -> bool {
380-
// We only support the new pass manager starting with LLVM 9.
381-
if llvm_util::get_major_version() < 9 {
382-
return false;
383-
}
384-
385380
// The new pass manager is disabled by default.
386381
config.new_llvm_pass_manager
387382
}

‎compiler/rustc_codegen_llvm/src/context.rs

-8
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@ fn to_llvm_tls_model(tls_model: TlsModel) -> llvm::ThreadLocalMode {
100100
}
101101
}
102102

103-
fn strip_function_ptr_alignment(data_layout: String) -> String {
104-
// FIXME: Make this more general.
105-
data_layout.replace("-Fi8-", "-")
106-
}
107-
108103
fn strip_x86_address_spaces(data_layout: String) -> String {
109104
data_layout.replace("-p270:32:32-p271:32:32-p272:64:64-", "-")
110105
}
@@ -119,9 +114,6 @@ pub unsafe fn create_module(
119114
let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx);
120115

121116
let mut target_data_layout = sess.target.data_layout.clone();
122-
if llvm_util::get_major_version() < 9 {
123-
target_data_layout = strip_function_ptr_alignment(target_data_layout);
124-
}
125117
if llvm_util::get_major_version() < 10
126118
&& (sess.target.arch == "x86" || sess.target.arch == "x86_64")
127119
{

‎compiler/rustc_codegen_llvm/src/llvm_util.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ unsafe fn configure_llvm(sess: &Session) {
104104
}
105105
}
106106

107-
if sess.opts.debugging_opts.llvm_time_trace && get_major_version() >= 9 {
107+
if sess.opts.debugging_opts.llvm_time_trace {
108108
// time-trace is not thread safe and running it in parallel will cause seg faults.
109109
if !sess.opts.debugging_opts.no_parallel_llvm {
110110
bug!("`-Z llvm-time-trace` requires `-Z no-parallel-llvm")
@@ -122,10 +122,8 @@ unsafe fn configure_llvm(sess: &Session) {
122122

123123
pub fn time_trace_profiler_finish(file_name: &str) {
124124
unsafe {
125-
if get_major_version() >= 9 {
126-
let file_name = CString::new(file_name).unwrap();
127-
llvm::LLVMTimeTraceProfilerFinish(file_name.as_ptr());
128-
}
125+
let file_name = CString::new(file_name).unwrap();
126+
llvm::LLVMTimeTraceProfilerFinish(file_name.as_ptr());
129127
}
130128
}
131129

‎compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+2-30
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
#include "llvm/Object/ObjectFile.h"
1717
#include "llvm/Object/IRObjectFile.h"
1818
#include "llvm/Passes/PassBuilder.h"
19-
#if LLVM_VERSION_GE(9, 0)
2019
#include "llvm/Passes/StandardInstrumentations.h"
21-
#endif
2220
#include "llvm/Support/CBindingWrapping.h"
2321
#include "llvm/Support/FileSystem.h"
2422
#include "llvm/Support/Host.h"
@@ -31,15 +29,11 @@
3129
#include "llvm-c/Transforms/PassManagerBuilder.h"
3230

3331
#include "llvm/Transforms/Instrumentation.h"
34-
#if LLVM_VERSION_GE(9, 0)
3532
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
3633
#include "llvm/Support/TimeProfiler.h"
37-
#endif
3834
#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
3935
#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
40-
#if LLVM_VERSION_GE(9, 0)
4136
#include "llvm/Transforms/Utils/CanonicalizeAliases.h"
42-
#endif
4337
#include "llvm/Transforms/Utils/NameAnonGlobals.h"
4438

4539
using namespace llvm;
@@ -73,20 +67,18 @@ extern "C" void LLVMTimeTraceProfilerInitialize() {
7367
timeTraceProfilerInitialize(
7468
/* TimeTraceGranularity */ 0,
7569
/* ProcName */ "rustc");
76-
#elif LLVM_VERSION_GE(9, 0)
70+
#else
7771
timeTraceProfilerInitialize();
7872
#endif
7973
}
8074

8175
extern "C" void LLVMTimeTraceProfilerFinish(const char* FileName) {
82-
#if LLVM_VERSION_GE(9, 0)
8376
StringRef FN(FileName);
8477
std::error_code EC;
8578
raw_fd_ostream OS(FN, EC, sys::fs::CD_CreateAlways);
8679

8780
timeTraceProfilerWrite(OS);
8881
timeTraceProfilerCleanup();
89-
#endif
9082
}
9183

9284
enum class LLVMRustPassKind {
@@ -127,22 +119,14 @@ extern "C" LLVMPassRef LLVMRustCreateAddressSanitizerFunctionPass(bool Recover)
127119
extern "C" LLVMPassRef LLVMRustCreateModuleAddressSanitizerPass(bool Recover) {
128120
const bool CompileKernel = false;
129121

130-
#if LLVM_VERSION_GE(9, 0)
131122
return wrap(createModuleAddressSanitizerLegacyPassPass(CompileKernel, Recover));
132-
#else
133-
return wrap(createAddressSanitizerModulePass(CompileKernel, Recover));
134-
#endif
135123
}
136124

137125
extern "C" LLVMPassRef LLVMRustCreateMemorySanitizerPass(int TrackOrigins, bool Recover) {
138-
#if LLVM_VERSION_GE(9, 0)
139126
const bool CompileKernel = false;
140127

141128
return wrap(createMemorySanitizerLegacyPassPass(
142129
MemorySanitizerOptions{TrackOrigins, Recover, CompileKernel}));
143-
#else
144-
return wrap(createMemorySanitizerLegacyPassPass(TrackOrigins, Recover));
145-
#endif
146130
}
147131

148132
extern "C" LLVMPassRef LLVMRustCreateThreadSanitizerPass() {
@@ -657,8 +641,6 @@ extern "C" typedef void (*LLVMRustSelfProfileBeforePassCallback)(void*, // LlvmS
657641
const char*); // IR name
658642
extern "C" typedef void (*LLVMRustSelfProfileAfterPassCallback)(void*); // LlvmSelfProfiler
659643

660-
#if LLVM_VERSION_GE(9, 0)
661-
662644
std::string LLVMRustwrappedIrGetName(const llvm::Any &WrappedIr) {
663645
if (any_isa<const Module *>(WrappedIr))
664646
return any_cast<const Module *>(WrappedIr)->getName().str();
@@ -706,7 +688,6 @@ void LLVMSelfProfileInitializeCallbacks(
706688
AfterPassCallback(LlvmSelfProfiler);
707689
});
708690
}
709-
#endif
710691

711692
enum class LLVMRustOptStage {
712693
PreLinkNoLTO,
@@ -739,7 +720,6 @@ LLVMRustOptimizeWithNewPassManager(
739720
void* LlvmSelfProfiler,
740721
LLVMRustSelfProfileBeforePassCallback BeforePassCallback,
741722
LLVMRustSelfProfileAfterPassCallback AfterPassCallback) {
742-
#if LLVM_VERSION_GE(9, 0)
743723
Module *TheModule = unwrap(ModuleRef);
744724
TargetMachine *TM = unwrap(TMRef);
745725
PassBuilder::OptimizationLevel OptLevel = fromRust(OptLevelRust);
@@ -970,11 +950,6 @@ LLVMRustOptimizeWithNewPassManager(
970950
UpgradeCallsToIntrinsic(&*I++); // must be post-increment, as we remove
971951

972952
MPM.run(*TheModule, MAM);
973-
#else
974-
// The new pass manager has been available for a long time,
975-
// but we don't bother supporting it on old LLVM versions.
976-
report_fatal_error("New pass manager only supported since LLVM 9");
977-
#endif
978953
}
979954

980955
// Callback to demangle function name
@@ -1325,12 +1300,9 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
13251300
GlobalValue::LinkageTypes NewLinkage) {
13261301
Ret->ResolvedODR[ModuleIdentifier][GUID] = NewLinkage;
13271302
};
1328-
#if LLVM_VERSION_GE(9, 0)
1303+
13291304
thinLTOResolvePrevailingInIndex(Ret->Index, isPrevailing, recordNewLinkage,
13301305
Ret->GUIDPreservedSymbols);
1331-
#else
1332-
thinLTOResolvePrevailingInIndex(Ret->Index, isPrevailing, recordNewLinkage);
1333-
#endif
13341306

13351307
// Here we calculate an `ExportedGUIDs` set for use in the `isExported`
13361308
// callback below. This callback below will dictate the linkage for all

‎compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ extern "C" LLVMValueRef LLVMRustGetOrInsertFunction(LLVMModuleRef M,
124124
return wrap(unwrap(M)
125125
->getOrInsertFunction(StringRef(Name, NameLen),
126126
unwrap<FunctionType>(FunctionTy))
127-
#if LLVM_VERSION_GE(9, 0)
128127
.getCallee()
129-
#endif
130128
);
131129
}
132130

@@ -251,11 +249,7 @@ extern "C" void LLVMRustAddDereferenceableOrNullCallSiteAttr(LLVMValueRef Instr,
251249
extern "C" void LLVMRustAddByValCallSiteAttr(LLVMValueRef Instr, unsigned Index,
252250
LLVMTypeRef Ty) {
253251
CallBase *Call = unwrap<CallBase>(Instr);
254-
#if LLVM_VERSION_GE(9, 0)
255252
Attribute Attr = Attribute::getWithByValType(Call->getContext(), unwrap(Ty));
256-
#else
257-
Attribute Attr = Attribute::get(Call->getContext(), Attribute::ByVal);
258-
#endif
259253
Call->addAttribute(Index, Attr);
260254
}
261255

@@ -296,11 +290,7 @@ extern "C" void LLVMRustAddDereferenceableOrNullAttr(LLVMValueRef Fn,
296290
extern "C" void LLVMRustAddByValAttr(LLVMValueRef Fn, unsigned Index,
297291
LLVMTypeRef Ty) {
298292
Function *F = unwrap<Function>(Fn);
299-
#if LLVM_VERSION_GE(9, 0)
300293
Attribute Attr = Attribute::getWithByValType(F->getContext(), unwrap(Ty));
301-
#else
302-
Attribute Attr = Attribute::get(F->getContext(), Attribute::ByVal);
303-
#endif
304294
F->addAttribute(Index, Attr);
305295
}
306296

@@ -616,11 +606,9 @@ static DISubprogram::DISPFlags fromRust(LLVMRustDISPFlags SPFlags) {
616606
if (isSet(SPFlags & LLVMRustDISPFlags::SPFlagOptimized)) {
617607
Result |= DISubprogram::DISPFlags::SPFlagOptimized;
618608
}
619-
#if LLVM_VERSION_GE(9, 0)
620609
if (isSet(SPFlags & LLVMRustDISPFlags::SPFlagMainSubprogram)) {
621610
Result |= DISubprogram::DISPFlags::SPFlagMainSubprogram;
622611
}
623-
#endif
624612

625613
return Result;
626614
}
@@ -744,10 +732,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction(
744732
DITemplateParameterArray(unwrap<MDTuple>(TParam));
745733
DISubprogram::DISPFlags llvmSPFlags = fromRust(SPFlags);
746734
DINode::DIFlags llvmFlags = fromRust(Flags);
747-
#if LLVM_VERSION_LT(9, 0)
748-
if (isSet(SPFlags & LLVMRustDISPFlags::SPFlagMainSubprogram))
749-
llvmFlags |= DINode::DIFlags::FlagMainSubprogram;
750-
#endif
751735
DISubprogram *Sub = Builder->createFunction(
752736
unwrapDI<DIScope>(Scope),
753737
StringRef(Name, NameLen),

‎src/bootstrap/native.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,11 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) {
348348
let version = output(cmd.arg("--version"));
349349
let mut parts = version.split('.').take(2).filter_map(|s| s.parse::<u32>().ok());
350350
if let (Some(major), Some(_minor)) = (parts.next(), parts.next()) {
351-
if major >= 8 {
351+
if major >= 9 {
352352
return;
353353
}
354354
}
355-
panic!("\n\nbad LLVM version: {}, need >=8.0\n\n", version)
355+
panic!("\n\nbad LLVM version: {}, need >=9.0\n\n", version)
356356
}
357357

358358
fn configure_cmake(

‎src/ci/docker/host-x86_64/x86_64-gnu-llvm-8/Dockerfile renamed to ‎src/ci/docker/host-x86_64/x86_64-gnu-llvm-9/Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1313
cmake \
1414
sudo \
1515
gdb \
16-
llvm-8-tools \
16+
llvm-9-tools \
17+
llvm-9-dev \
1718
libedit-dev \
1819
libssl-dev \
1920
pkg-config \
@@ -27,7 +28,7 @@ RUN sh /scripts/sccache.sh
2728
# using llvm-link-shared due to libffi issues -- see #34486
2829
ENV RUST_CONFIGURE_ARGS \
2930
--build=x86_64-unknown-linux-gnu \
30-
--llvm-root=/usr/lib/llvm-8 \
31+
--llvm-root=/usr/lib/llvm-9 \
3132
--enable-llvm-link-shared \
3233
--set rust.thin-lto-import-instr-limit=10
3334

‎src/ci/github-actions/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ jobs:
280280
- name: mingw-check
281281
<<: *job-linux-xl
282282

283-
- name: x86_64-gnu-llvm-8
283+
- name: x86_64-gnu-llvm-9
284284
<<: *job-linux-xl
285285

286286
- name: x86_64-gnu-tools
@@ -412,7 +412,7 @@ jobs:
412412
- name: x86_64-gnu-distcheck
413413
<<: *job-linux-xl
414414

415-
- name: x86_64-gnu-llvm-8
415+
- name: x86_64-gnu-llvm-9
416416
env:
417417
RUST_BACKTRACE: 1
418418
<<: *job-linux-xl

‎src/test/codegen/abi-efiapi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Checks if the correct annotation for the efiapi ABI is passed to llvm.
22

33
// revisions:x86_64 i686 aarch64 arm riscv
4-
// min-llvm-version: 9.0
54
// needs-llvm-components: aarch64 arm riscv
65

76
//[x86_64] compile-flags: --target x86_64-unknown-uefi

‎src/test/codegen/force-unwind-tables.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// min-llvm-version: 8.0
21
// compile-flags: -C no-prepopulate-passes -C force-unwind-tables=y
32

43
#![crate_type="lib"]

‎src/test/ui/sanitize/new-llvm-pass-manager-thin-lto.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// being run when compiling with new LLVM pass manager and ThinLTO.
33
// Note: The issue occurred only on non-zero opt-level.
44
//
5-
// min-llvm-version: 9.0
65
// needs-sanitizer-support
76
// needs-sanitizer-address
87
//

0 commit comments

Comments
 (0)
Please sign in to comment.