]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_codegen_llvm/context.rs
Rollup merge of #68485 - kingslef:fix/test-60976, r=nikomatsakis
[rust.git] / src / librustc_codegen_llvm / context.rs
index 746b76ad1c7d0223fbcea28e08ebe471245a79f7..50a35fe3dcf1db17f988566c0de2b0bc54de926b 100644 (file)
@@ -5,7 +5,6 @@
 use crate::llvm_util;
 use crate::value::Value;
 use rustc::dep_graph::DepGraphSafe;
-use rustc::hir;
 
 use crate::type_::Type;
 use rustc_codegen_ssa::traits::*;
@@ -24,6 +23,7 @@
 use rustc_data_structures::const_cstr;
 use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::small_c_str::SmallCStr;
+use rustc_hir::Unsafety;
 use rustc_target::spec::{HasTargetSpec, Target};
 
 use crate::abi::Abi;
@@ -143,6 +143,10 @@ fn strip_function_ptr_alignment(data_layout: String) -> String {
     data_layout.replace("-Fi8-", "-")
 }
 
+fn strip_x86_address_spaces(data_layout: String) -> String {
+    data_layout.replace("-p270:32:32-p271:32:32-p272:64:64-", "-")
+}
+
 pub unsafe fn create_module(
     tcx: TyCtxt<'_>,
     llcx: &'ll llvm::Context,
@@ -156,6 +160,11 @@ pub unsafe fn create_module(
     if llvm_util::get_major_version() < 9 {
         target_data_layout = strip_function_ptr_alignment(target_data_layout);
     }
+    if llvm_util::get_major_version() < 10 {
+        if sess.target.target.arch == "x86" || sess.target.target.arch == "x86_64" {
+            target_data_layout = strip_x86_address_spaces(target_data_layout);
+        }
+    }
 
     // Ensure the data-layout values hardcoded remain the defaults.
     if sess.target.target.options.is_builtin {
@@ -415,7 +424,7 @@ fn eh_unwind_resume(&self) -> &'ll Value {
             iter::once(tcx.mk_mut_ptr(tcx.types.u8)),
             tcx.types.never,
             false,
-            hir::Unsafety::Unsafe,
+            Unsafety::Unsafe,
             Abi::C,
         ));