Skip to content

Commit 63f8e6e

Browse files
committed
Auto merge of #56642 - nikic:llvm-6, r=alexcrichton
Bump minimum required LLVM version to 6.0 Based on the discussion in #55842, while the overall position of Rust wrt LLVM continues to be contentious, there does seem to be a consensus that there is no need for continued support of LLVM 5. This PR bumps our version requirement to LLVM 6.0 and makes Travis run against that. I hope that this is going to unblock #52694. If I understand correctly, while this issue still exists in LLVM 6, Ubuntu has backported the relevant patch. r? @alexcrichton
2 parents c6fb01d + 6c2d704 commit 63f8e6e

22 files changed

+16
-95
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ matrix:
1616
fast_finish: true
1717
include:
1818
# Images used in testing PR and try-build should be run first.
19-
- env: IMAGE=x86_64-gnu-llvm-5.0 RUST_BACKTRACE=1
19+
- env: IMAGE=x86_64-gnu-llvm-6.0 RUST_BACKTRACE=1
2020
if: type = pull_request OR branch = auto
2121

2222
- env: IMAGE=dist-x86_64-linux DEPLOY=1

src/bootstrap/native.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,11 @@ fn check_llvm_version(builder: &Builder, llvm_config: &Path) {
278278
let mut parts = version.split('.').take(2)
279279
.filter_map(|s| s.parse::<u32>().ok());
280280
if let (Some(major), Some(_minor)) = (parts.next(), parts.next()) {
281-
if major >= 5 {
281+
if major >= 6 {
282282
return
283283
}
284284
}
285-
panic!("\n\nbad LLVM version: {}, need >=5.0\n\n", version)
285+
panic!("\n\nbad LLVM version: {}, need >=6.0\n\n", version)
286286
}
287287

288288
fn configure_cmake(builder: &Builder,

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1111
cmake \
1212
sudo \
1313
gdb \
14-
llvm-5.0-tools \
14+
llvm-6.0-tools \
1515
libedit-dev \
1616
zlib1g-dev \
1717
xz-utils
@@ -22,6 +22,6 @@ RUN sh /scripts/sccache.sh
2222
# using llvm-link-shared due to libffi issues -- see #34486
2323
ENV RUST_CONFIGURE_ARGS \
2424
--build=x86_64-unknown-linux-gnu \
25-
--llvm-root=/usr/lib/llvm-5.0 \
25+
--llvm-root=/usr/lib/llvm-6.0 \
2626
--enable-llvm-link-shared
2727
ENV RUST_CHECK_TARGET check

src/librustc_codegen_llvm/builder.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -1024,17 +1024,11 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
10241024

10251025
fn minnum(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
10261026
self.count_insn("minnum");
1027-
unsafe {
1028-
let instr = llvm::LLVMRustBuildMinNum(self.llbuilder, lhs, rhs);
1029-
instr.expect("LLVMRustBuildMinNum is not available in LLVM version < 6.0")
1030-
}
1027+
unsafe { llvm::LLVMRustBuildMinNum(self.llbuilder, lhs, rhs) }
10311028
}
10321029
fn maxnum(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
10331030
self.count_insn("maxnum");
1034-
unsafe {
1035-
let instr = llvm::LLVMRustBuildMaxNum(self.llbuilder, lhs, rhs);
1036-
instr.expect("LLVMRustBuildMaxNum is not available in LLVM version < 6.0")
1037-
}
1031+
unsafe { llvm::LLVMRustBuildMaxNum(self.llbuilder, lhs, rhs) }
10381032
}
10391033

10401034
fn select(

src/librustc_codegen_llvm/context.rs

-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use attributes;
1212
use llvm;
13-
use llvm_util;
1413
use rustc::dep_graph::DepGraphSafe;
1514
use rustc::hir;
1615
use debuginfo;
@@ -446,10 +445,6 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
446445
attributes::apply_target_cpu_attr(self, llfn)
447446
}
448447

449-
fn closure_env_needs_indirect_debuginfo(&self) -> bool {
450-
llvm_util::get_major_version() < 6
451-
}
452-
453448
fn create_used_variable(&self) {
454449
let name = const_cstr!("llvm.used");
455450
let section = const_cstr!("llvm.metadata");

src/librustc_codegen_llvm/llvm/ffi.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1222,12 +1222,12 @@ extern "C" {
12221222
B: &Builder<'a>,
12231223
LHS: &'a Value,
12241224
LHS: &'a Value,
1225-
) -> Option<&'a Value>;
1225+
) -> &'a Value;
12261226
pub fn LLVMRustBuildMaxNum(
12271227
B: &Builder<'a>,
12281228
LHS: &'a Value,
12291229
LHS: &'a Value,
1230-
) -> Option<&'a Value>;
1230+
) -> &'a Value;
12311231

12321232
// Atomic Operations
12331233
pub fn LLVMRustBuildAtomicLoad(B: &Builder<'a>,

src/librustc_codegen_ssa/mir/mod.rs

+2-24
Original file line numberDiff line numberDiff line change
@@ -610,35 +610,13 @@ fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
610610
};
611611
let upvar_tys = upvar_substs.upvar_tys(def_id, tcx);
612612

613-
// Store the pointer to closure data in an alloca for debuginfo
614-
// because that's what the llvm.dbg.declare intrinsic expects.
615-
616-
// FIXME(eddyb) this shouldn't be necessary but SROA seems to
617-
// mishandle DW_OP_plus not preceded by DW_OP_deref, i.e., it
618-
// doesn't actually strip the offset when splitting the closure
619-
// environment into its components so it ends up out of bounds.
620-
// (cuviper) It seems to be fine without the alloca on LLVM 6 and later.
621-
let env_alloca = !env_ref && bx.closure_env_needs_indirect_debuginfo();
622-
let env_ptr = if env_alloca {
623-
let scratch = PlaceRef::alloca(bx,
624-
bx.layout_of(tcx.mk_mut_ptr(arg.layout.ty)),
625-
"__debuginfo_env_ptr");
626-
bx.store(place.llval, scratch.llval, scratch.align);
627-
scratch.llval
628-
} else {
629-
place.llval
630-
};
631-
632613
for (i, (decl, ty)) in mir.upvar_decls.iter().zip(upvar_tys).enumerate() {
633614
let byte_offset_of_var_in_env = closure_layout.fields.offset(i).bytes();
634615

635616
let ops = bx.debuginfo_upvar_decls_ops_sequence(byte_offset_of_var_in_env);
636617

637618
// The environment and the capture can each be indirect.
638-
639-
// FIXME(eddyb) see above why we sometimes have to keep
640-
// a pointer in an alloca for debuginfo atm.
641-
let mut ops = if env_ref || env_alloca { &ops[..] } else { &ops[1..] };
619+
let mut ops = if env_ref { &ops[..] } else { &ops[1..] };
642620

643621
let ty = if let (true, &ty::Ref(_, ty, _)) = (decl.by_ref, &ty.sty) {
644622
ty
@@ -648,7 +626,7 @@ fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
648626
};
649627

650628
let variable_access = VariableAccess::IndirectVariable {
651-
alloca: env_ptr,
629+
alloca: place.llval,
652630
address_operations: &ops
653631
};
654632
bx.declare_local(

src/librustc_codegen_ssa/traits/misc.rs

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pub trait MiscMethods<'tcx>: BackendTypes {
3232
fn stats(&self) -> &RefCell<Stats>;
3333
fn consume_stats(self) -> RefCell<Stats>;
3434
fn codegen_unit(&self) -> &Arc<CodegenUnit<'tcx>>;
35-
fn closure_env_needs_indirect_debuginfo(&self) -> bool;
3635
fn used_statics(&self) -> &RefCell<Vec<Self::Value>>;
3736
fn set_frame_pointer_elimination(&self, llfn: Self::Value);
3837
fn apply_target_cpu_attr(&self, llfn: Self::Value);

src/rustllvm/ArchiveWrapper.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,11 @@ LLVMRustWriteArchive(char *Dst, size_t NumMembers,
216216
Members.push_back(std::move(*MOrErr));
217217
}
218218
}
219+
219220
auto Result = writeArchive(Dst, Members, WriteSymbtab, Kind, true, false);
220-
#if LLVM_VERSION_GE(6, 0)
221221
if (!Result)
222222
return LLVMRustResult::Success;
223223
LLVMRustSetLastError(toString(std::move(Result)).c_str());
224-
#else
225-
if (!Result.second)
226-
return LLVMRustResult::Success;
227-
LLVMRustSetLastError(Result.second.message().c_str());
228-
#endif
229224

230225
return LLVMRustResult::Failure;
231226
}

src/rustllvm/PassWrapper.cpp

+2-16
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,15 @@
1717

1818
#include "llvm/Analysis/TargetLibraryInfo.h"
1919
#include "llvm/Analysis/TargetTransformInfo.h"
20+
#include "llvm/CodeGen/TargetSubtargetInfo.h"
2021
#include "llvm/IR/AutoUpgrade.h"
2122
#include "llvm/IR/AssemblyAnnotationWriter.h"
23+
#include "llvm/IR/IntrinsicInst.h"
2224
#include "llvm/Support/CBindingWrapping.h"
2325
#include "llvm/Support/FileSystem.h"
2426
#include "llvm/Support/Host.h"
2527
#include "llvm/Target/TargetMachine.h"
2628
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
27-
28-
#if LLVM_VERSION_GE(6, 0)
29-
#include "llvm/CodeGen/TargetSubtargetInfo.h"
30-
#include "llvm/IR/IntrinsicInst.h"
31-
#else
32-
#include "llvm/Target/TargetSubtargetInfo.h"
33-
#endif
34-
3529
#include "llvm/Transforms/IPO/AlwaysInliner.h"
3630
#include "llvm/Transforms/IPO/FunctionImport.h"
3731
#include "llvm/Transforms/Utils/FunctionImportUtils.h"
@@ -198,13 +192,9 @@ GEN_SUBTARGETS
198192

199193
extern "C" bool LLVMRustHasFeature(LLVMTargetMachineRef TM,
200194
const char *Feature) {
201-
#if LLVM_VERSION_GE(6, 0)
202195
TargetMachine *Target = unwrap(TM);
203196
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
204197
return MCInfo->checkFeatures(std::string("+") + Feature);
205-
#else
206-
return false;
207-
#endif
208198
}
209199

210200
enum class LLVMRustCodeModel {
@@ -392,13 +382,9 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
392382
Options.ThreadModel = ThreadModel::Single;
393383
}
394384

395-
#if LLVM_VERSION_GE(6, 0)
396385
Options.EmitStackSizeSection = EmitStackSizeSection;
397386

398387
Optional<CodeModel::Model> CM;
399-
#else
400-
CodeModel::Model CM = CodeModel::Model::Default;
401-
#endif
402388
if (RustCM != LLVMRustCodeModel::None)
403389
CM = fromRust(RustCM);
404390
TargetMachine *TM = TheTarget->createTargetMachine(

src/rustllvm/RustWrapper.cpp

-15
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,7 @@ extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn,
297297
// enable fpmath flag UnsafeAlgebra
298298
extern "C" void LLVMRustSetHasUnsafeAlgebra(LLVMValueRef V) {
299299
if (auto I = dyn_cast<Instruction>(unwrap<Value>(V))) {
300-
#if LLVM_VERSION_GE(6, 0)
301300
I->setFast(true);
302-
#else
303-
I->setHasUnsafeAlgebra(true);
304-
#endif
305301
}
306302
}
307303

@@ -1437,7 +1433,6 @@ LLVMRustBuildVectorReduceFMax(LLVMBuilderRef B, LLVMValueRef Src, bool NoNaN) {
14371433
return wrap(unwrap(B)->CreateFPMaxReduce(unwrap(Src), NoNaN));
14381434
}
14391435

1440-
#if LLVM_VERSION_GE(6, 0)
14411436
extern "C" LLVMValueRef
14421437
LLVMRustBuildMinNum(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS) {
14431438
return wrap(unwrap(B)->CreateMinNum(unwrap(LHS),unwrap(RHS)));
@@ -1446,13 +1441,3 @@ extern "C" LLVMValueRef
14461441
LLVMRustBuildMaxNum(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS) {
14471442
return wrap(unwrap(B)->CreateMaxNum(unwrap(LHS),unwrap(RHS)));
14481443
}
1449-
#else
1450-
extern "C" LLVMValueRef
1451-
LLVMRustBuildMinNum(LLVMBuilderRef, LLVMValueRef, LLVMValueRef) {
1452-
return nullptr;
1453-
}
1454-
extern "C" LLVMValueRef
1455-
LLVMRustBuildMaxNum(LLVMBuilderRef, LLVMValueRef, LLVMValueRef) {
1456-
return nullptr;
1457-
}
1458-
#endif

src/test/codegen/function-arguments.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// compile-flags: -C no-prepopulate-passes
1212
// ignore-tidy-linelength
13-
// min-llvm-version 6.0
1413

1514
#![crate_type = "lib"]
1615
#![feature(custom_attribute)]

src/test/codegen/issue-44056-macos-tls-align.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// ignore-tidy-linelength
1212
// only-macos
1313
// no-system-llvm
14-
// min-llvm-version 6.0
1514
// compile-flags: -O
1615

1716
#![crate_type = "rlib"]

src/test/codegen/issue-45222.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
// compile-flags: -O
12-
// min-llvm-version 6.0
1312

1413
#![crate_type = "lib"]
1514

src/test/codegen/issue-45466.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
// compile-flags: -O
12-
// min-llvm-version 6.0
1312

1413
#![crate_type="rlib"]
1514

src/test/codegen/simd-intrinsic-generic-gather.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// ignore-emscripten
1212
// ignore-tidy-linelength
13-
// min-llvm-version 6.0
1413

1514
// compile-flags: -C no-prepopulate-passes
1615

src/test/codegen/simd-intrinsic-generic-scatter.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// ignore-emscripten
1212
// ignore-tidy-linelength
13-
// min-llvm-version 6.0
1413

1514
// compile-flags: -C no-prepopulate-passes
1615

src/test/codegen/vtabletype.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// ignore-tidy-linelength
1515
// ignore-windows
1616
// ignore-macos
17-
// min-llvm-version 6.0
1817

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

src/test/run-pass/simd/simd-intrinsic-generic-gather.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// run-pass
1212
// ignore-emscripten
13-
// min-llvm-version 6.0
1413

1514
// Test that the simd_{gather,scatter} intrinsics produce the correct results.
1615

src/test/run-pass/sse2.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![allow(stable_features)]
12-
// min-llvm-version 6.0
13-
// ^ needs MCSubtargetInfo::checkFeatures()
1411
// ignore-cloudabi no std::env
1512

13+
#![allow(stable_features)]
1614
#![feature(cfg_target_feature)]
1715

1816
use std::env;

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

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
// gate-test-mips_target_feature
2525
// gate-test-mmx_target_feature
2626
// gate-test-wasm_target_feature
27-
// min-llvm-version 6.0
2827

2928
#[target_feature(enable = "avx512bw")]
3029
//~^ 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 (see issue #44839)
2-
--> $DIR/target-feature-gate.rs:29:18
2+
--> $DIR/target-feature-gate.rs:28:18
33
|
44
LL | #[target_feature(enable = "avx512bw")]
55
| ^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)