about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-01-19 01:58:30 +0000
committerbors <bors@rust-lang.org>2018-01-19 01:58:30 +0000
commit9af8d42ec79558225043189e429e9d652ff89eab (patch)
tree385cea7a6d78c729c60990ae2e0950916f11f62f /src
parent3bd4af88bea2e6ecdd3455ed89b3ef1fc3500aa4 (diff)
parent9eb473579a19f456e53920dd6e6f8e75eb08dc62 (diff)
downloadrust-9af8d42ec79558225043189e429e9d652ff89eab.tar.gz
rust-9af8d42ec79558225043189e429e9d652ff89eab.zip
Auto merge of #47401 - rkruppe:issue-47278, r=eddyb
Compute LLVM argument indices correctly in face of padding

Closes #47278

r? @eddyb
Diffstat (limited to 'src')
-rw-r--r--src/librustc_trans/abi.rs3
-rw-r--r--src/librustc_trans/mir/mod.rs3
-rw-r--r--src/test/codegen/issue-47278.rs19
3 files changed, 22 insertions, 3 deletions
diff --git a/src/librustc_trans/abi.rs b/src/librustc_trans/abi.rs
index 07f9b8fed8b..5079ce77523 100644
--- a/src/librustc_trans/abi.rs
+++ b/src/librustc_trans/abi.rs
@@ -608,9 +608,6 @@ impl<'a, 'tcx> ArgType<'tcx> {
     }
 
     pub fn store_fn_arg(&self, bx: &Builder<'a, 'tcx>, idx: &mut usize, dst: PlaceRef<'tcx>) {
-        if self.pad.is_some() {
-            *idx += 1;
-        }
         let mut next = || {
             let val = llvm::get_param(bx.llfn(), *idx as c_uint);
             *idx += 1;
diff --git a/src/librustc_trans/mir/mod.rs b/src/librustc_trans/mir/mod.rs
index ddd78f268fa..3064e2f7c7a 100644
--- a/src/librustc_trans/mir/mod.rs
+++ b/src/librustc_trans/mir/mod.rs
@@ -402,6 +402,9 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
             for i in 0..tupled_arg_tys.len() {
                 let arg = &fx.fn_ty.args[idx];
                 idx += 1;
+                if arg.pad.is_some() {
+                    llarg_idx += 1;
+                }
                 arg.store_fn_arg(bx, &mut llarg_idx, place.project_field(bx, i));
             }
 
diff --git a/src/test/codegen/issue-47278.rs b/src/test/codegen/issue-47278.rs
new file mode 100644
index 00000000000..21858b434bf
--- /dev/null
+++ b/src/test/codegen/issue-47278.rs
@@ -0,0 +1,19 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// -C no-prepopulate-passes
+#![crate_type="staticlib"]
+
+#[repr(C)]
+pub struct Foo(u64);
+
+// CHECK: define {{.*}} @foo(
+#[no_mangle]
+pub extern fn foo(_: Foo) -> Foo { loop {} }