about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/builder.rs14
-rw-r--r--src/consts.rs9
-rw-r--r--src/lib.rs2
3 files changed, 21 insertions, 4 deletions
diff --git a/src/builder.rs b/src/builder.rs
index f85971d1657..c5819ff93d7 100644
--- a/src/builder.rs
+++ b/src/builder.rs
@@ -252,7 +252,19 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
                     {
                         self.context.new_cast(self.location, actual_val, expected_ty)
                     } else if on_stack_param_indices.contains(&index) {
-                        actual_val.dereference(self.location).to_rvalue()
+                        let ty = actual_val.get_type();
+                        if let Some(pointee_val) = ty.get_pointee()
+                            && pointee_val != expected_ty
+                        {
+                            let new_val = self.context.new_cast(
+                                self.location,
+                                actual_val,
+                                expected_ty.make_pointer(),
+                            );
+                            new_val.dereference(self.location).to_rvalue()
+                        } else {
+                            actual_val.dereference(self.location).to_rvalue()
+                        }
                     } else {
                         assert!(
                             !((actual_ty.is_vector() && !expected_ty.is_vector())
diff --git a/src/consts.rs b/src/consts.rs
index be44ebe0698..735793baf61 100644
--- a/src/consts.rs
+++ b/src/consts.rs
@@ -254,8 +254,13 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
             }
 
             let is_tls = fn_attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL);
-            let global =
-                self.declare_global(sym, gcc_type, GlobalKind::Exported, is_tls, fn_attrs.link_section);
+            let global = self.declare_global(
+                sym,
+                gcc_type,
+                GlobalKind::Exported,
+                is_tls,
+                fn_attrs.link_section,
+            );
 
             if !self.tcx.is_reachable_non_generic(def_id) {
                 #[cfg(feature = "master")]
diff --git a/src/lib.rs b/src/lib.rs
index 24856506c46..d8393856955 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -16,7 +16,7 @@
 #![allow(internal_features)]
 #![doc(rust_logo)]
 #![feature(rustdoc_internals)]
-#![feature(rustc_private, decl_macro, never_type, trusted_len, hash_raw_entry)]
+#![feature(rustc_private, decl_macro, never_type, trusted_len, hash_raw_entry, let_chains)]
 #![allow(broken_intra_doc_links)]
 #![recursion_limit = "256"]
 #![warn(rust_2018_idioms)]