about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2018-01-26 06:51:14 -0800
committerAlex Crichton <alex@alexcrichton.com>2018-01-26 06:51:14 -0800
commita7f41567c52bf4ce851963809ca3c08cfeffab79 (patch)
treef214c341b7b11724f7dacf72b218dd5057a18d35 /src
parent6da912e2a1f8ef5df8e0669713d15258a039325f (diff)
parent7eb7d45c0b0a9dc0454c5f3a3c5e911c7900bbea (diff)
downloadrust-a7f41567c52bf4ce851963809ca3c08cfeffab79.tar.gz
rust-a7f41567c52bf4ce851963809ca3c08cfeffab79.zip
Merge branch 'llvm5-indirect-deref' of https://github.com/cuviper/rust into rollup
Diffstat (limited to 'src')
-rw-r--r--src/librustc_trans/mir/mod.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/librustc_trans/mir/mod.rs b/src/librustc_trans/mir/mod.rs
index b367eb6548d..da01592d911 100644
--- a/src/librustc_trans/mir/mod.rs
+++ b/src/librustc_trans/mir/mod.rs
@@ -487,16 +487,18 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
                 // The Rust ABI passes indirect variables using a pointer and a manual copy, so we
                 // need to insert a deref here, but the C ABI uses a pointer and a copy using the
                 // byval attribute, for which LLVM does the deref itself, so we must not add it.
+                // Starting with D31439 in LLVM 5, it *always* does the deref itself.
                 let mut variable_access = VariableAccess::DirectVariable {
                     alloca: place.llval
                 };
-
-                if let PassMode::Indirect(ref attrs) = arg.mode {
-                    if !attrs.contains(ArgAttribute::ByVal) {
-                        variable_access = VariableAccess::IndirectVariable {
-                            alloca: place.llval,
-                            address_operations: &deref_op,
-                        };
+                if unsafe { llvm::LLVMRustVersionMajor() < 5 } {
+                    if let PassMode::Indirect(ref attrs) = arg.mode {
+                        if !attrs.contains(ArgAttribute::ByVal) {
+                            variable_access = VariableAccess::IndirectVariable {
+                                alloca: place.llval,
+                                address_operations: &deref_op,
+                            };
+                        }
                     }
                 }