Skip to content

Commit

Permalink
Auto merge of #51899 - gnzlbg:llvm501, r=alexcrichton
Browse files Browse the repository at this point in the history
bump minimum LLVM version to 5.0

Closes #51878 .

r? @alexcrichton

--

cc @cuviper @infinity0
  • Loading branch information
bors committed Jul 9, 2018
2 parents 9bd8458 + 3b36ce6 commit 5b52591
Show file tree
Hide file tree
Showing 30 changed files with 17 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ matrix:
fast_finish: true
include:
# Images used in testing PR and try-build should be run first.
- env: IMAGE=x86_64-gnu-llvm-3.9 RUST_BACKTRACE=1
- env: IMAGE=x86_64-gnu-llvm-5.0 RUST_BACKTRACE=1
if: type = pull_request OR branch = auto

- env: IMAGE=dist-x86_64-linux DEPLOY=1
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ 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 > 3 || (major == 3 && minor >= 9) {
if let (Some(major), Some(_minor)) = (parts.next(), parts.next()) {
if major >= 5 {
return
}
}
panic!("\n\nbad LLVM version: {}, need >=3.9\n\n", version)
panic!("\n\nbad LLVM version: {}, need >=5.0\n\n", version)
}

fn configure_cmake(builder: &Builder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
llvm-3.9-tools \
llvm-5.0-tools \
libedit-dev \
zlib1g-dev \
xz-utils
Expand All @@ -22,6 +22,6 @@ 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-3.9 \
--llvm-root=/usr/lib/llvm-5.0 \
--enable-llvm-link-shared
ENV RUST_CHECK_TARGET check
6 changes: 1 addition & 5 deletions src/librustc_codegen_llvm/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,11 +666,7 @@ impl<'a, 'tcx> FnTypeExt<'a, 'tcx> for FnType<'tcx, Ty<'tcx>> {
layout::Int(..) if !scalar.is_bool() => {
let range = scalar.valid_range_exclusive(bx.cx);
if range.start != range.end {
// FIXME(nox): This causes very weird type errors about
// SHL operators in constants in stage 2 with LLVM 3.9.
if unsafe { llvm::LLVMRustVersionMajor() >= 4 } {
bx.range_metadata(callsite, range);
}
bx.range_metadata(callsite, range);
}
}
_ => {}
Expand Down
22 changes: 4 additions & 18 deletions src/librustc_codegen_llvm/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use builder::Builder;
use common::{CodegenCx, Funclet};
use debuginfo::{self, declare_local, VariableAccess, VariableKind, FunctionDebugContext};
use monomorphize::Instance;
use abi::{ArgAttribute, ArgTypeExt, FnType, FnTypeExt, PassMode};
use abi::{ArgTypeExt, FnType, FnTypeExt, PassMode};
use type_::Type;

use syntax_pos::{DUMMY_SP, NO_EXPANSION, BytePos, Span};
Expand Down Expand Up @@ -430,10 +430,6 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
None
};

let deref_op = unsafe {
[llvm::LLVMRustDIBuilderCreateOpDeref()]
};

mir.args_iter().enumerate().map(|(arg_index, local)| {
let arg_decl = &mir.local_decls[local];

Expand Down Expand Up @@ -543,21 +539,11 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
if arg_index > 0 || mir.upvar_decls.is_empty() {
// The Rust ABI passes indirect variables using a pointer and a manual copy, so we
// need to insert a deref here, but the C ABI uses a pointer and a copy using the
// byval attribute, for which LLVM does the deref itself, so we must not add it.
// Starting with D31439 in LLVM 5, it *always* does the deref itself.
let mut variable_access = VariableAccess::DirectVariable {
// byval attribute, for which LLVM always does the deref itself,
// so we must not add it.
let variable_access = VariableAccess::DirectVariable {
alloca: place.llval
};
if unsafe { llvm::LLVMRustVersionMajor() < 5 } {
if let PassMode::Indirect(ref attrs) = arg.mode {
if !attrs.contains(ArgAttribute::ByVal) {
variable_access = VariableAccess::IndirectVariable {
alloca: place.llval,
address_operations: &deref_op,
};
}
}
}

declare_local(
bx,
Expand Down
33 changes: 2 additions & 31 deletions src/rustllvm/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,13 +492,8 @@ inline LLVMRustDIFlags visibility(LLVMRustDIFlags F) {
return static_cast<LLVMRustDIFlags>(static_cast<uint32_t>(F) & 0x3);
}

#if LLVM_VERSION_GE(4, 0)
static DINode::DIFlags fromRust(LLVMRustDIFlags Flags) {
DINode::DIFlags Result = DINode::DIFlags::FlagZero;
#else
static unsigned fromRust(LLVMRustDIFlags Flags) {
unsigned Result = 0;
#endif

switch (visibility(Flags)) {
case LLVMRustDIFlags::FlagPrivate:
Expand Down Expand Up @@ -565,14 +560,12 @@ static unsigned fromRust(LLVMRustDIFlags Flags) {
if (isSet(Flags & LLVMRustDIFlags::FlagBitField)) {
Result |= DINode::DIFlags::FlagBitField;
}
#if LLVM_RUSTLLVM || LLVM_VERSION_GE(4, 0)
if (isSet(Flags & LLVMRustDIFlags::FlagNoReturn)) {
Result |= DINode::DIFlags::FlagNoReturn;
}
if (isSet(Flags & LLVMRustDIFlags::FlagMainSubprogram)) {
Result |= DINode::DIFlags::FlagMainSubprogram;
}
#endif

return Result;
}
Expand Down Expand Up @@ -612,14 +605,8 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateCompileUnit(
unsigned RuntimeVer, const char *SplitName) {
auto *File = unwrapDI<DIFile>(FileRef);

#if LLVM_VERSION_GE(4, 0)
return wrap(Builder->createCompileUnit(Lang, File, Producer, isOptimized,
Flags, RuntimeVer, SplitName));
#else
return wrap(Builder->createCompileUnit(Lang, File->getFilename(),
File->getDirectory(), Producer, isOptimized,
Flags, RuntimeVer, SplitName));
#endif
}

extern "C" LLVMMetadataRef
Expand Down Expand Up @@ -657,11 +644,7 @@ extern "C" LLVMMetadataRef
LLVMRustDIBuilderCreateBasicType(LLVMRustDIBuilderRef Builder, const char *Name,
uint64_t SizeInBits, uint32_t AlignInBits,
unsigned Encoding) {
return wrap(Builder->createBasicType(Name, SizeInBits,
#if LLVM_VERSION_LE(3, 9)
AlignInBits,
#endif
Encoding));
return wrap(Builder->createBasicType(Name, SizeInBits, Encoding));
}

extern "C" LLVMMetadataRef LLVMRustDIBuilderCreatePointerType(
Expand Down Expand Up @@ -722,7 +705,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticVariable(
LLVMMetadataRef Decl = nullptr, uint32_t AlignInBits = 0) {
llvm::GlobalVariable *InitVal = cast<llvm::GlobalVariable>(unwrap(V));

#if LLVM_VERSION_GE(4, 0)
llvm::DIExpression *InitExpr = nullptr;
if (llvm::ConstantInt *IntVal = llvm::dyn_cast<llvm::ConstantInt>(InitVal)) {
InitExpr = Builder->createConstantValueExpression(
Expand All @@ -741,12 +723,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticVariable(
InitVal->setMetadata("dbg", VarExpr);

return wrap(VarExpr);
#else
return wrap(Builder->createGlobalVariable(
unwrapDI<DIDescriptor>(Context), Name, LinkageName,
unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), IsLocalToUnit,
InitVal, unwrapDIPtr<MDNode>(Decl)));
#endif
}

extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariable(
Expand All @@ -757,12 +733,7 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariable(
if (Tag == 0x100) { // DW_TAG_auto_variable
return wrap(Builder->createAutoVariable(
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNo,
unwrapDI<DIType>(Ty), AlwaysPreserve, fromRust(Flags)
#if LLVM_VERSION_GE(4, 0)
,
AlignInBits
#endif
));
unwrapDI<DIType>(Ty), AlwaysPreserve, fromRust(Flags), AlignInBits));
} else {
return wrap(Builder->createParameterVariable(
unwrapDI<DIDescriptor>(Scope), Name, ArgNo, unwrapDI<DIFile>(File),
Expand Down
2 changes: 0 additions & 2 deletions src/test/codegen/call-metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// scalar value.

// compile-flags: -C no-prepopulate-passes
// min-llvm-version 4.0


#![crate_type = "lib"]

Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/issue-37945.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// min-llvm-version 4.0
// compile-flags: -O
// ignore-x86
// ignore-arm
Expand Down
2 changes: 1 addition & 1 deletion src/test/codegen/issue-45466.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// min-llvm-version 4.0
// compile-flags: -O
// min-llvm-version 6.0

#![crate_type="rlib"]

Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/mainsubprogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// ignore-tidy-linelength
// ignore-windows
// ignore-macos
// min-llvm-version 4.0

// compile-flags: -g -C no-prepopulate-passes

Expand Down
4 changes: 0 additions & 4 deletions src/test/codegen/mainsubprogramstart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// This test depends on a patch that was committed to upstream LLVM
// before 4.0, formerly backported to the Rust LLVM fork.

// ignore-tidy-linelength
// ignore-windows
// ignore-macos
// min-llvm-version 4.0

// compile-flags: -g -C no-prepopulate-passes

Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/noreturnflag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// compile-flags: -g -C no-prepopulate-passes
// ignore-tidy-linelength
// min-llvm-version 4.0

#![crate_type = "lib"]

Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/stack-probes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
// ignore-wasm
// ignore-emscripten
// ignore-windows
// min-system-llvm-version 5.0
// compile-flags: -C no-prepopulate-passes

#![crate_type = "lib"]
Expand Down
2 changes: 1 addition & 1 deletion src/test/codegen/vtabletype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// ignore-tidy-linelength
// ignore-windows
// ignore-macos
// min-system-llvm-version 5.1
// min-llvm-version 6.0

// compile-flags: -g -C no-prepopulate-passes

Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/simd-intrinsic-generic-reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// min-llvm-version 5.0
// ignore-emscripten

// Test that the simd_reduce_{op} intrinsics produce ok-ish error
Expand Down
3 changes: 0 additions & 3 deletions src/test/mir-opt/lower_128bit_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// asmjs can't even pass i128 as arguments or return values, so ignore it.
// this will hopefully be fixed by the LLVM 5 upgrade (#43370)
// ignore-asmjs
// ignore-emscripten

// compile-flags: -Z lower_128bit_ops=yes -C debug_assertions=no
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-make-fulldeps/cross-lang-lto/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

# min-llvm-version 4.0
# ignore-msvc

-include ../tools.mk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ namespace {

bool runOnFunction(Function &F) override;

#if LLVM_VERSION_MAJOR >= 4
StringRef
#else
const char *
#endif
getPassName() const override {
StringRef getPassName() const override {
return "Some LLVM pass";
}

Expand Down
7 changes: 1 addition & 6 deletions src/test/run-make-fulldeps/llvm-pass/llvm-module-pass.so.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ namespace {

bool runOnModule(Module &M) override;

#if LLVM_VERSION_MAJOR >= 4
StringRef
#else
const char *
#endif
getPassName() const override {
StringRef getPassName() const override {
return "Some LLVM pass";
}

Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/issue-40883.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

// check that we don't have linear stack usage with multiple calls to `push`
// min-llvm-version 4.0

#![feature(test)]

Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/simd-intrinsic-generic-reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// min-llvm-version 5.0
// ignore-emscripten

// Test that the simd_reduce_{op} intrinsics produce the correct results.
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/stack-probes-lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
// ignore-emscripten no processes
// ignore-musl FIXME #31506
// ignore-pretty
// min-system-llvm-version 5.0
// compile-flags: -C lto
// no-prefer-dynamic

Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/stack-probes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
// ignore-cloudabi no processes
// ignore-emscripten no processes
// ignore-musl FIXME #31506
// min-system-llvm-version 5.0

use std::mem;
use std::process::Command;
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/thin-lto-global-allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

// compile-flags: -Z thinlto -C codegen-units=2
// min-llvm-version 4.0

#[global_allocator]
static A: std::alloc::System = std::alloc::System;
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/thinlto/all-crates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// compile-flags: -Clto=thin
// no-prefer-dynamic
// min-llvm-version 4.0

fn main() {
println!("hello!");
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/thinlto/dylib-works.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

// aux-build:dylib.rs
// min-llvm-version 4.0

extern crate dylib;

Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/thinlto/msvc-imp-present.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// aux-build:msvc-imp-present.rs
// compile-flags: -Z thinlto -C codegen-units=8
// min-llvm-version: 4.0
// no-prefer-dynamic

// On MSVC we have a "hack" where we emit symbols that look like `_imp_$name`
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/thinlto/thin-lto-inlines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

// compile-flags: -Z thinlto -C codegen-units=8 -O
// min-llvm-version 4.0
// ignore-emscripten can't inspect instructions on emscripten

// We want to assert here that ThinLTO will inline across codegen units. There's
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/thinlto/thin-lto-inlines2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// compile-flags: -C codegen-units=8 -O -C lto=thin
// aux-build:thin-lto-inlines-aux.rs
// min-llvm-version 4.0
// no-prefer-dynamic
// ignore-emscripten can't inspect instructions on emscripten

Expand Down
Loading

0 comments on commit 5b52591

Please sign in to comment.