about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2020-04-14 12:10:58 -0700
committerJosh Stone <jistone@redhat.com>2020-04-14 12:44:41 -0700
commit8506bb006040cf8e8cb004202706c81e62ddacee (patch)
tree2e374e4dcad22b16ecf717fa309e3d4813d5a6fe /src/librustc_codegen_llvm
parentba72b15666b2491415aec703a02c2364fe5e2790 (diff)
downloadrust-8506bb006040cf8e8cb004202706c81e62ddacee.tar.gz
rust-8506bb006040cf8e8cb004202706c81e62ddacee.zip
Update the minimum external LLVM to 8
LLVM 8 was released on March 20, 2019, over a year ago.
Diffstat (limited to 'src/librustc_codegen_llvm')
-rw-r--r--src/librustc_codegen_llvm/attributes.rs21
-rw-r--r--src/librustc_codegen_llvm/debuginfo/metadata.rs18
-rw-r--r--src/librustc_codegen_llvm/intrinsic.rs51
-rw-r--r--src/librustc_codegen_llvm/llvm_util.rs20
4 files changed, 27 insertions, 83 deletions
diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs
index 784a3a87e98..004de8d8ca9 100644
--- a/src/librustc_codegen_llvm/attributes.rs
+++ b/src/librustc_codegen_llvm/attributes.rs
@@ -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"),
+        );
     }
 }
 
diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs
index 82cd8589327..03bba7657bb 100644
--- a/src/librustc_codegen_llvm/debuginfo/metadata.rs
+++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs
@@ -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;
@@ -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
diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs
index 63730c56f0e..86d10e91d6d 100644
--- a/src/librustc_codegen_llvm/intrinsic.rs
+++ b/src/librustc_codegen_llvm/intrinsic.rs
@@ -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;
@@ -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;
@@ -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!(),
                     },
diff --git a/src/librustc_codegen_llvm/llvm_util.rs b/src/librustc_codegen_llvm/llvm_util.rs
index a56c8802f3c..6f16b0fb79c 100644
--- a/src/librustc_codegen_llvm/llvm_util.rs
+++ b/src/librustc_codegen_llvm/llvm_util.rs
@@ -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);
             }
         }