Skip to content

Commit 8dcb532

Browse files
authored
Rollup merge of #66973 - cuviper:min-llvm7, r=alexcrichton
Update the minimum external LLVM to 7 LLVM 7 is over a year old, which should be plenty for compatibility. The last LLVM 6 holdout was llvm-emscripten, which went away in #65501. I've also included a fix for LLVM 8 lacking `MemorySanitizerOptions`, which was broken by #66522.
2 parents ded9885 + 2304c25 commit 8dcb532

File tree

18 files changed

+16
-95
lines changed

18 files changed

+16
-95
lines changed

src/bootstrap/native.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,11 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) {
294294
let mut parts = version.split('.').take(2)
295295
.filter_map(|s| s.parse::<u32>().ok());
296296
if let (Some(major), Some(_minor)) = (parts.next(), parts.next()) {
297-
if major >= 6 {
297+
if major >= 7 {
298298
return
299299
}
300300
}
301-
panic!("\n\nbad LLVM version: {}, need >=6.0\n\n", version)
301+
panic!("\n\nbad LLVM version: {}, need >=7.0\n\n", version)
302302
}
303303

304304
fn configure_cmake(builder: &Builder<'_>,

src/ci/azure-pipelines/auto.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- template: steps/run.yml
1919
strategy:
2020
matrix:
21-
x86_64-gnu-llvm-6.0:
21+
x86_64-gnu-llvm-7:
2222
RUST_BACKTRACE: 1
2323
dist-x86_64-linux: {}
2424
dist-x86_64-linux-alt:

src/ci/azure-pipelines/pr.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- template: steps/run.yml
1919
strategy:
2020
matrix:
21-
x86_64-gnu-llvm-6.0: {}
21+
x86_64-gnu-llvm-7: {}
2222
mingw-check: {}
2323
x86_64-gnu-tools:
2424
CI_ONLY_WHEN_SUBMODULES_CHANGED: 1

src/ci/docker/x86_64-gnu-llvm-6.0/Dockerfile src/ci/docker/x86_64-gnu-llvm-7/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:16.04
1+
FROM ubuntu:18.04
22

33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
@@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1111
cmake \
1212
sudo \
1313
gdb \
14-
llvm-6.0-tools \
14+
llvm-7-tools \
1515
libedit-dev \
1616
libssl-dev \
1717
pkg-config \
@@ -24,7 +24,7 @@ RUN sh /scripts/sccache.sh
2424
# using llvm-link-shared due to libffi issues -- see #34486
2525
ENV RUST_CONFIGURE_ARGS \
2626
--build=x86_64-unknown-linux-gnu \
27-
--llvm-root=/usr/lib/llvm-6.0 \
27+
--llvm-root=/usr/lib/llvm-7 \
2828
--enable-llvm-link-shared
2929
ENV SCRIPT python2.7 ../x.py test src/tools/tidy && python2.7 ../x.py test
3030

src/librustc_codegen_llvm/intrinsic.rs

+5-26
Original file line numberDiff line numberDiff line change
@@ -442,32 +442,11 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
442442
let is_left = name == "rotate_left";
443443
let val = args[0].immediate();
444444
let raw_shift = args[1].immediate();
445-
if llvm_util::get_major_version() >= 7 {
446-
// rotate = funnel shift with first two args the same
447-
let llvm_name = &format!("llvm.fsh{}.i{}",
448-
if is_left { 'l' } else { 'r' }, width);
449-
let llfn = self.get_intrinsic(llvm_name);
450-
self.call(llfn, &[val, val, raw_shift], None)
451-
} else {
452-
// rotate_left: (X << (S % BW)) | (X >> ((BW - S) % BW))
453-
// rotate_right: (X << ((BW - S) % BW)) | (X >> (S % BW))
454-
let width = self.const_uint(
455-
self.type_ix(width),
456-
width,
457-
);
458-
let shift = self.urem(raw_shift, width);
459-
let width_minus_raw_shift = self.sub(width, raw_shift);
460-
let inv_shift = self.urem(width_minus_raw_shift, width);
461-
let shift1 = self.shl(
462-
val,
463-
if is_left { shift } else { inv_shift },
464-
);
465-
let shift2 = self.lshr(
466-
val,
467-
if !is_left { shift } else { inv_shift },
468-
);
469-
self.or(shift1, shift2)
470-
}
445+
// rotate = funnel shift with first two args the same
446+
let llvm_name = &format!("llvm.fsh{}.i{}",
447+
if is_left { 'l' } else { 'r' }, width);
448+
let llfn = self.get_intrinsic(llvm_name);
449+
self.call(llfn, &[val, val, raw_shift], None)
471450
},
472451
"saturating_add" | "saturating_sub" => {
473452
let is_add = name == "saturating_add";

src/rustllvm/PassWrapper.cpp

+3-13
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,13 @@ extern "C" LLVMPassRef LLVMRustCreateModuleAddressSanitizerPass(bool Recover) {
101101
}
102102

103103
extern "C" LLVMPassRef LLVMRustCreateMemorySanitizerPass(int TrackOrigins, bool Recover) {
104-
#if LLVM_VERSION_GE(8, 0)
104+
#if LLVM_VERSION_GE(9, 0)
105105
const bool CompileKernel = false;
106106

107107
return wrap(createMemorySanitizerLegacyPassPass(
108108
MemorySanitizerOptions{TrackOrigins, Recover, CompileKernel}));
109+
#elif LLVM_VERSION_GE(8, 0)
110+
return wrap(createMemorySanitizerLegacyPassPass(TrackOrigins, Recover));
109111
#else
110112
return wrap(createMemorySanitizerPass(TrackOrigins, Recover));
111113
#endif
@@ -451,9 +453,7 @@ extern "C" void LLVMRustConfigurePassManagerBuilder(
451453
LLVMPassManagerBuilderRef PMBR, LLVMRustCodeGenOptLevel OptLevel,
452454
bool MergeFunctions, bool SLPVectorize, bool LoopVectorize, bool PrepareForThinLTO,
453455
const char* PGOGenPath, const char* PGOUsePath) {
454-
#if LLVM_VERSION_GE(7, 0)
455456
unwrap(PMBR)->MergeFunctions = MergeFunctions;
456-
#endif
457457
unwrap(PMBR)->SLPVectorize = SLPVectorize;
458458
unwrap(PMBR)->OptLevel = fromRust(OptLevel);
459459
unwrap(PMBR)->LoopVectorize = LoopVectorize;
@@ -560,12 +560,8 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR,
560560
return LLVMRustResult::Failure;
561561
}
562562

563-
#if LLVM_VERSION_GE(7, 0)
564563
buffer_ostream BOS(OS);
565564
unwrap(Target)->addPassesToEmitFile(*PM, BOS, nullptr, FileType, false);
566-
#else
567-
unwrap(Target)->addPassesToEmitFile(*PM, OS, FileType, false);
568-
#endif
569565
PM->run(*unwrap(M));
570566

571567
// Apparently `addPassesToEmitFile` adds a pointer to our on-the-stack output
@@ -849,9 +845,7 @@ struct LLVMRustThinLTOData {
849845
StringMap<FunctionImporter::ExportSetTy> ExportLists;
850846
StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries;
851847

852-
#if LLVM_VERSION_GE(7, 0)
853848
LLVMRustThinLTOData() : Index(/* HaveGVs = */ false) {}
854-
#endif
855849
};
856850

857851
// Just an argument to the `LLVMRustCreateThinLTOData` function below.
@@ -922,7 +916,6 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
922916
// combined index
923917
//
924918
// This is copied from `lib/LTO/ThinLTOCodeGenerator.cpp`
925-
#if LLVM_VERSION_GE(7, 0)
926919
auto deadIsPrevailing = [&](GlobalValue::GUID G) {
927920
return PrevailingType::Unknown;
928921
};
@@ -934,9 +927,6 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
934927
deadIsPrevailing, /* ImportEnabled = */ false);
935928
#else
936929
computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
937-
#endif
938-
#else
939-
computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols);
940930
#endif
941931
ComputeCrossModuleImport(
942932
Ret->Index,

src/rustllvm/RustWrapper.cpp

-37
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,7 @@ extern "C" char *LLVMRustGetLastError(void) {
8888
}
8989

9090
extern "C" unsigned int LLVMRustGetInstructionCount(LLVMModuleRef M) {
91-
#if LLVM_VERSION_GE(7, 0)
9291
return unwrap(M)->getInstructionCount();
93-
#else
94-
report_fatal_error("Module::getInstructionCount not available before LLVM 7");
95-
#endif
9692
}
9793

9894
extern "C" void LLVMRustSetLastError(const char *Err) {
@@ -761,14 +757,10 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantPart(
761757
LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
762758
uint32_t AlignInBits, LLVMRustDIFlags Flags, LLVMMetadataRef Discriminator,
763759
LLVMMetadataRef Elements, const char *UniqueId) {
764-
#if LLVM_VERSION_GE(7, 0)
765760
return wrap(Builder->createVariantPart(
766761
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber,
767762
SizeInBits, AlignInBits, fromRust(Flags), unwrapDI<DIDerivedType>(Discriminator),
768763
DINodeArray(unwrapDI<MDTuple>(Elements)), UniqueId));
769-
#else
770-
abort();
771-
#endif
772764
}
773765

774766
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateMemberType(
@@ -787,7 +779,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantMemberType(
787779
const char *Name, LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits,
788780
uint32_t AlignInBits, uint64_t OffsetInBits, LLVMValueRef Discriminant,
789781
LLVMRustDIFlags Flags, LLVMMetadataRef Ty) {
790-
#if LLVM_VERSION_GE(7, 0)
791782
llvm::ConstantInt* D = nullptr;
792783
if (Discriminant) {
793784
D = unwrap<llvm::ConstantInt>(Discriminant);
@@ -796,12 +787,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantMemberType(
796787
unwrapDI<DIFile>(File), LineNo,
797788
SizeInBits, AlignInBits, OffsetInBits, D,
798789
fromRust(Flags), unwrapDI<DIType>(Ty)));
799-
#else
800-
return wrap(Builder->createMemberType(unwrapDI<DIDescriptor>(Scope), Name,
801-
unwrapDI<DIFile>(File), LineNo,
802-
SizeInBits, AlignInBits, OffsetInBits,
803-
fromRust(Flags), unwrapDI<DIType>(Ty)));
804-
#endif
805790
}
806791

807792
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateLexicalBlock(
@@ -911,18 +896,10 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateEnumerationType(
911896
LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
912897
uint32_t AlignInBits, LLVMMetadataRef Elements,
913898
LLVMMetadataRef ClassTy, bool IsScoped) {
914-
#if LLVM_VERSION_GE(7, 0)
915899
return wrap(Builder->createEnumerationType(
916900
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber,
917901
SizeInBits, AlignInBits, DINodeArray(unwrapDI<MDTuple>(Elements)),
918902
unwrapDI<DIType>(ClassTy), "", IsScoped));
919-
#else
920-
// Ignore IsScoped on older LLVM.
921-
return wrap(Builder->createEnumerationType(
922-
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber,
923-
SizeInBits, AlignInBits, DINodeArray(unwrapDI<MDTuple>(Elements)),
924-
unwrapDI<DIType>(ClassTy), ""));
925-
#endif
926903
}
927904

928905
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateUnionType(
@@ -1275,34 +1252,20 @@ extern "C" LLVMValueRef LLVMRustBuildMemCpy(LLVMBuilderRef B,
12751252
LLVMValueRef Dst, unsigned DstAlign,
12761253
LLVMValueRef Src, unsigned SrcAlign,
12771254
LLVMValueRef Size, bool IsVolatile) {
1278-
#if LLVM_VERSION_GE(7, 0)
12791255
return wrap(unwrap(B)->CreateMemCpy(
12801256
unwrap(Dst), DstAlign,
12811257
unwrap(Src), SrcAlign,
12821258
unwrap(Size), IsVolatile));
1283-
#else
1284-
unsigned Align = std::min(DstAlign, SrcAlign);
1285-
return wrap(unwrap(B)->CreateMemCpy(
1286-
unwrap(Dst), unwrap(Src),
1287-
unwrap(Size), Align, IsVolatile));
1288-
#endif
12891259
}
12901260

12911261
extern "C" LLVMValueRef LLVMRustBuildMemMove(LLVMBuilderRef B,
12921262
LLVMValueRef Dst, unsigned DstAlign,
12931263
LLVMValueRef Src, unsigned SrcAlign,
12941264
LLVMValueRef Size, bool IsVolatile) {
1295-
#if LLVM_VERSION_GE(7, 0)
12961265
return wrap(unwrap(B)->CreateMemMove(
12971266
unwrap(Dst), DstAlign,
12981267
unwrap(Src), SrcAlign,
12991268
unwrap(Size), IsVolatile));
1300-
#else
1301-
unsigned Align = std::min(DstAlign, SrcAlign);
1302-
return wrap(unwrap(B)->CreateMemMove(
1303-
unwrap(Dst), unwrap(Src),
1304-
unwrap(Size), Align, IsVolatile));
1305-
#endif
13061269
}
13071270

13081271
extern "C" LLVMValueRef

src/test/codegen/align-enum.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// compile-flags: -C no-prepopulate-passes
22
// ignore-tidy-linelength
3-
// min-llvm-version 7.0
43

54
#![crate_type = "lib"]
65

src/test/codegen/align-struct.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// compile-flags: -C no-prepopulate-passes
22
// ignore-tidy-linelength
3-
// min-llvm-version 7.0
43

54
#![crate_type = "lib"]
65

src/test/codegen/consts.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// compile-flags: -C no-prepopulate-passes
22
// ignore-tidy-linelength
3-
// min-llvm-version 7.0
43

54
#![crate_type = "lib"]
65

src/test/codegen/packed.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// ignore-tidy-linelength
22
// compile-flags: -C no-prepopulate-passes
3-
// min-llvm-version 7.0
43

54
#![crate_type = "lib"]
65

src/test/codegen/repeat-trusted-len.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// compile-flags: -O
22
// ignore-tidy-linelength
3-
// min-llvm-version 7.0
43

54
#![crate_type = "lib"]
65

src/test/codegen/simd-intrinsic/simd-intrinsic-float-minmax.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// min-llvm-version 7.0
2-
31
// compile-flags: -C no-prepopulate-passes
42

53
#![crate_type = "lib"]

src/test/codegen/stores.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// compile-flags: -C no-prepopulate-passes
22
// ignore-tidy-linelength
3-
// min-llvm-version 7.0
43

54
#![crate_type = "lib"]
65

src/test/run-make-fulldeps/emit-stack-sizes/Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
# ignore-windows
44
# ignore-macos
5-
# min-llvm-version 6.0
65
#
76
# This feature only works when the output object format is ELF so we ignore
87
# macOS and Windows

src/test/ui/simd/simd-intrinsic-float-minmax.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22
// ignore-emscripten
3-
// min-llvm-version 7.0
43

54
// Test that the simd_f{min,max} intrinsics produce the correct results.
65

src/test/ui/target-feature/gate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
// gate-test-movbe_target_feature
2626
// gate-test-rtm_target_feature
2727
// gate-test-f16c_target_feature
28-
// min-llvm-version 6.0
2928

3029
#[target_feature(enable = "avx512bw")]
3130
//~^ ERROR: currently unstable

src/test/ui/target-feature/gate.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: the target feature `avx512bw` is currently unstable
2-
--> $DIR/gate.rs:30:18
2+
--> $DIR/gate.rs:29:18
33
|
44
LL | #[target_feature(enable = "avx512bw")]
55
| ^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)