Skip to content

Commit

Permalink
Auto merge of rust-lang#71147 - cuviper:min-llvm8, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Update the minimum external LLVM to 8

LLVM 8 was released on March 20, 2019, over a year ago.
  • Loading branch information
bors committed Apr 18, 2020
2 parents cff9a75 + 8506bb0 commit 28742a1
Show file tree
Hide file tree
Showing 30 changed files with 67 additions and 195 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Expand Up @@ -36,13 +36,13 @@ jobs:
matrix:
name:
- mingw-check
- x86_64-gnu-llvm-7
- x86_64-gnu-llvm-8
- x86_64-gnu-tools
include:
- name: mingw-check
os: ubuntu-latest-xl
env: {}
- name: x86_64-gnu-llvm-7
- name: x86_64-gnu-llvm-8
os: ubuntu-latest-xl
env: {}
- name: x86_64-gnu-tools
Expand Down Expand Up @@ -352,7 +352,7 @@ jobs:
- x86_64-gnu-debug
- x86_64-gnu-distcheck
- x86_64-gnu-full-bootstrap
- x86_64-gnu-llvm-7
- x86_64-gnu-llvm-8
- x86_64-gnu-nopt
- x86_64-gnu-tools
- x86_64-mingw-1
Expand Down Expand Up @@ -469,7 +469,7 @@ jobs:
- name: x86_64-gnu-full-bootstrap
os: ubuntu-latest-xl
env: {}
- name: x86_64-gnu-llvm-7
- name: x86_64-gnu-llvm-8
env:
RUST_BACKTRACE: 1
os: ubuntu-latest-xl
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/native.rs
Expand Up @@ -289,11 +289,11 @@ 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 >= 7 {
if major >= 8 {
return;
}
}
panic!("\n\nbad LLVM version: {}, need >=7.0\n\n", version)
panic!("\n\nbad LLVM version: {}, need >=8.0\n\n", version)
}

fn configure_cmake(
Expand Down
2 changes: 1 addition & 1 deletion src/ci/azure-pipelines/auto.yml
Expand Up @@ -29,7 +29,7 @@ jobs:
- template: steps/run.yml
strategy:
matrix:
x86_64-gnu-llvm-7:
x86_64-gnu-llvm-8:
RUST_BACKTRACE: 1
dist-x86_64-linux: {}
dist-x86_64-linux-alt:
Expand Down
2 changes: 1 addition & 1 deletion src/ci/azure-pipelines/pr.yml
Expand Up @@ -29,7 +29,7 @@ jobs:
- template: steps/run.yml
strategy:
matrix:
x86_64-gnu-llvm-7: {}
x86_64-gnu-llvm-8: {}
mingw-check: {}
x86_64-gnu-tools:
CI_ONLY_WHEN_SUBMODULES_CHANGED: 1
Expand Up @@ -12,7 +12,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
llvm-7-tools \
llvm-8-tools \
libedit-dev \
libssl-dev \
pkg-config \
Expand All @@ -26,7 +26,7 @@ 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-7 \
--llvm-root=/usr/lib/llvm-8 \
--enable-llvm-link-shared \
--set rust.thin-lto-import-instr-limit=10

Expand Down
8 changes: 4 additions & 4 deletions src/ci/github-actions/ci.yml
Expand Up @@ -259,13 +259,13 @@ jobs:
matrix:
name:
- mingw-check
- x86_64-gnu-llvm-7
- x86_64-gnu-llvm-8
- x86_64-gnu-tools
include:
- name: mingw-check
<<: *job-linux-xl

- name: x86_64-gnu-llvm-7
- name: x86_64-gnu-llvm-8
<<: *job-linux-xl

- name: x86_64-gnu-tools
Expand Down Expand Up @@ -349,7 +349,7 @@ jobs:
- x86_64-gnu-debug
- x86_64-gnu-distcheck
- x86_64-gnu-full-bootstrap
- x86_64-gnu-llvm-7
- x86_64-gnu-llvm-8
- x86_64-gnu-nopt
- x86_64-gnu-tools
- x86_64-mingw-1
Expand Down Expand Up @@ -471,7 +471,7 @@ jobs:
- name: x86_64-gnu-full-bootstrap
<<: *job-linux-xl

- name: x86_64-gnu-llvm-7
- name: x86_64-gnu-llvm-8
env:
RUST_BACKTRACE: 1
<<: *job-linux-xl
Expand Down
21 changes: 6 additions & 15 deletions src/librustc_codegen_llvm/attributes.rs
Expand Up @@ -82,21 +82,12 @@ fn naked(val: &'ll Value, is_naked: bool) {

pub fn set_frame_pointer_elimination(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
if cx.sess().must_not_eliminate_frame_pointers() {
if llvm_util::get_major_version() >= 8 {
llvm::AddFunctionAttrStringValue(
llfn,
llvm::AttributePlace::Function,
const_cstr!("frame-pointer"),
const_cstr!("all"),
);
} else {
llvm::AddFunctionAttrStringValue(
llfn,
llvm::AttributePlace::Function,
const_cstr!("no-frame-pointer-elim"),
const_cstr!("true"),
);
}
llvm::AddFunctionAttrStringValue(
llfn,
llvm::AttributePlace::Function,
const_cstr!("frame-pointer"),
const_cstr!("all"),
);
}
}

Expand Down
18 changes: 3 additions & 15 deletions src/librustc_codegen_llvm/debuginfo/metadata.rs
Expand Up @@ -16,7 +16,6 @@ use crate::llvm::debuginfo::{
DIArray, DICompositeType, DIDescriptor, DIFile, DIFlags, DILexicalBlock, DIScope, DIType,
DebugEmissionKind,
};
use crate::llvm_util;
use crate::value::Value;

use log::debug;
Expand Down Expand Up @@ -1289,22 +1288,11 @@ fn prepare_union_metadata(
// Enums
//=-----------------------------------------------------------------------------

/// DWARF variant support is only available starting in LLVM 8.
/// Although the earlier enum debug info output did not work properly
/// in all situations, it is better for the time being to continue to
/// sometimes emit the old style rather than emit something completely
/// useless when rust is compiled against LLVM 6 or older. LLVM 7
/// contains an early version of the DWARF variant support, and will
/// crash when handling the new debug info format. This function
/// decides which representation will be emitted.
/// DWARF variant support is only available starting in LLVM 8, but
/// on MSVC we have to use the fallback mode, because LLVM doesn't
/// lower variant parts to PDB.
fn use_enum_fallback(cx: &CodegenCx<'_, '_>) -> bool {
// On MSVC we have to use the fallback mode, because LLVM doesn't
// lower variant parts to PDB.
cx.sess().target.target.options.is_like_msvc
// LLVM version 7 did not release with an important bug fix;
// but the required patch is in the LLVM 8. Rust LLVM reports
// 8 as well.
|| llvm_util::get_major_version() < 8
}

// FIXME(eddyb) maybe precompute this? Right now it's computed once
Expand Down
51 changes: 9 additions & 42 deletions src/librustc_codegen_llvm/intrinsic.rs
Expand Up @@ -2,7 +2,6 @@ use crate::abi::{Abi, FnAbi, LlvmType, PassMode};
use crate::builder::Builder;
use crate::context::CodegenCx;
use crate::llvm;
use crate::llvm_util;
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt;
use crate::va_arg::emit_va_arg;
Expand All @@ -11,7 +10,7 @@ use crate::value::Value;
use rustc_ast::ast;
use rustc_codegen_ssa::base::{compare_simd_types, to_immediate, wants_msvc_seh};
use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
use rustc_codegen_ssa::common::TypeKind;
use rustc_codegen_ssa::glue;
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
use rustc_codegen_ssa::mir::place::PlaceRef;
Expand Down Expand Up @@ -461,46 +460,14 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
let is_add = name == "saturating_add";
let lhs = args[0].immediate();
let rhs = args[1].immediate();
if llvm_util::get_major_version() >= 8 {
let llvm_name = &format!(
"llvm.{}{}.sat.i{}",
if signed { 's' } else { 'u' },
if is_add { "add" } else { "sub" },
width
);
let llfn = self.get_intrinsic(llvm_name);
self.call(llfn, &[lhs, rhs], None)
} else {
let llvm_name = &format!(
"llvm.{}{}.with.overflow.i{}",
if signed { 's' } else { 'u' },
if is_add { "add" } else { "sub" },
width
);
let llfn = self.get_intrinsic(llvm_name);
let pair = self.call(llfn, &[lhs, rhs], None);
let val = self.extract_value(pair, 0);
let overflow = self.extract_value(pair, 1);
let llty = self.type_ix(width);

let limit = if signed {
let limit_lo = self
.const_uint_big(llty, (i128::MIN >> (128 - width)) as u128);
let limit_hi = self
.const_uint_big(llty, (i128::MAX >> (128 - width)) as u128);
let neg = self.icmp(
IntPredicate::IntSLT,
val,
self.const_uint(llty, 0),
);
self.select(neg, limit_hi, limit_lo)
} else if is_add {
self.const_uint_big(llty, u128::MAX >> (128 - width))
} else {
self.const_uint(llty, 0)
};
self.select(overflow, limit, val)
}
let llvm_name = &format!(
"llvm.{}{}.sat.i{}",
if signed { 's' } else { 'u' },
if is_add { "add" } else { "sub" },
width
);
let llfn = self.get_intrinsic(llvm_name);
self.call(llfn, &[lhs, rhs], None)
}
_ => bug!(),
},
Expand Down
20 changes: 9 additions & 11 deletions src/librustc_codegen_llvm/llvm_util.rs
Expand Up @@ -83,17 +83,15 @@ unsafe fn configure_llvm(sess: &Session) {
if !sess.opts.debugging_opts.no_generate_arange_section {
add("-generate-arange-section", false);
}
if get_major_version() >= 8 {
match sess
.opts
.debugging_opts
.merge_functions
.unwrap_or(sess.target.target.options.merge_functions)
{
MergeFunctions::Disabled | MergeFunctions::Trampolines => {}
MergeFunctions::Aliases => {
add("-mergefunc-use-aliases", false);
}
match sess
.opts
.debugging_opts
.merge_functions
.unwrap_or(sess.target.target.options.merge_functions)
{
MergeFunctions::Disabled | MergeFunctions::Trampolines => {}
MergeFunctions::Aliases => {
add("-mergefunc-use-aliases", false);
}
}

Expand Down
22 changes: 2 additions & 20 deletions src/rustllvm/PassWrapper.cpp
Expand Up @@ -33,10 +33,8 @@
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
#include "llvm/Support/TimeProfiler.h"
#endif
#if LLVM_VERSION_GE(8, 0)
#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
#endif
#if LLVM_VERSION_GE(9, 0)
#include "llvm/Transforms/Utils/CanonicalizeAliases.h"
#endif
Expand Down Expand Up @@ -138,19 +136,13 @@ extern "C" LLVMPassRef LLVMRustCreateMemorySanitizerPass(int TrackOrigins, bool

return wrap(createMemorySanitizerLegacyPassPass(
MemorySanitizerOptions{TrackOrigins, Recover, CompileKernel}));
#elif LLVM_VERSION_GE(8, 0)
return wrap(createMemorySanitizerLegacyPassPass(TrackOrigins, Recover));
#else
return wrap(createMemorySanitizerPass(TrackOrigins, Recover));
return wrap(createMemorySanitizerLegacyPassPass(TrackOrigins, Recover));
#endif
}

extern "C" LLVMPassRef LLVMRustCreateThreadSanitizerPass() {
#if LLVM_VERSION_GE(8, 0)
return wrap(createThreadSanitizerLegacyPassPass());
#else
return wrap(createThreadSanitizerPass());
#endif
}

extern "C" LLVMRustPassKind LLVMRustPassKind(LLVMPassRef RustPass) {
Expand Down Expand Up @@ -1236,15 +1228,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
auto deadIsPrevailing = [&](GlobalValue::GUID G) {
return PrevailingType::Unknown;
};
#if LLVM_VERSION_GE(8, 0)
// We don't have a complete picture in our use of ThinLTO, just our immediate
// crate, so we need `ImportEnabled = false` to limit internalization.
// Otherwise, we sometimes lose `static` values -- see #60184.
computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
deadIsPrevailing, /* ImportEnabled = */ false);
#else
computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
#endif
ComputeCrossModuleImport(
Ret->Index,
Ret->ModuleToDefinedGVSummaries,
Expand Down Expand Up @@ -1277,10 +1265,8 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
#if LLVM_VERSION_GE(9, 0)
thinLTOResolvePrevailingInIndex(Ret->Index, isPrevailing, recordNewLinkage,
Ret->GUIDPreservedSymbols);
#elif LLVM_VERSION_GE(8, 0)
thinLTOResolvePrevailingInIndex(Ret->Index, isPrevailing, recordNewLinkage);
#else
thinLTOResolveWeakForLinkerInIndex(Ret->Index, isPrevailing, recordNewLinkage);
thinLTOResolvePrevailingInIndex(Ret->Index, isPrevailing, recordNewLinkage);
#endif

// Here we calculate an `ExportedGUIDs` set for use in the `isExported`
Expand Down Expand Up @@ -1346,11 +1332,7 @@ extern "C" bool
LLVMRustPrepareThinLTOResolveWeak(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
Module &Mod = *unwrap(M);
const auto &DefinedGlobals = Data->ModuleToDefinedGVSummaries.lookup(Mod.getModuleIdentifier());
#if LLVM_VERSION_GE(8, 0)
thinLTOResolvePrevailingInModule(Mod, DefinedGlobals);
#else
thinLTOResolveWeakForLinkerModule(Mod, DefinedGlobals);
#endif
return true;
}

Expand Down

0 comments on commit 28742a1

Please sign in to comment.