Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a384f13

Browse files
committedApr 11, 2017
Fix handling of closure arguments
Those did not take tuple reordering into account, causing majority of the compiler test suite to fail.
1 parent d821e98 commit a384f13

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed
 

‎src/librustc/ty/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ impl<'a, 'gcx, 'tcx> Struct {
598598
// In addition, code in trans assume that 2-element structs can become pairs.
599599
// It's easier to just short-circuit here.
600600
let can_optimize = (fields.len() > 2 || StructKind::EnumVariant == kind)
601-
&& ! (repr.c || repr.packed || repr.linear || repr.simd);
601+
&& !(repr.c || repr.packed || repr.linear || repr.simd);
602602

603603
let (optimize, sort_ascending) = match kind {
604604
StructKind::AlwaysSizedUnivariant => (can_optimize, false),

‎src/librustc/ty/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,8 @@ impl_stable_hash_for!(struct ReprOptions {
14191419
c,
14201420
packed,
14211421
simd,
1422-
int
1422+
int,
1423+
linear
14231424
});
14241425

14251426
impl ReprOptions {

‎src/librustc_trans/intrinsic.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use llvm;
1616
use llvm::{ValueRef};
1717
use abi::{Abi, FnType};
1818
use adt;
19-
use mir::lvalue::LvalueRef;
19+
use mir::lvalue::{LvalueRef, Alignment};
2020
use base::*;
2121
use common::*;
2222
use declare;
@@ -36,8 +36,6 @@ use syntax_pos::Span;
3636
use std::cmp::Ordering;
3737
use std::iter;
3838

39-
use mir::lvalue::Alignment;
40-
4139
fn get_simple_intrinsic(ccx: &CrateContext, name: &str) -> Option<ValueRef> {
4240
let llvm_name = match name {
4341
"sqrtf32" => "llvm.sqrt.f32",
@@ -622,7 +620,10 @@ pub fn trans_intrinsic_call<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
622620

623621
for i in 0..elems.len() {
624622
let val = bcx.extract_value(val, i);
625-
bcx.store(val, bcx.struct_gep(llresult, i), None);
623+
let lval = LvalueRef::new_sized_ty(llresult, ret_ty,
624+
Alignment::AbiAligned);
625+
let (dest, _) = lval.trans_field_ptr(bcx, i);
626+
bcx.store(val, dest, None);
626627
}
627628
C_nil(ccx)
628629
}

‎src/librustc_trans/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ fn arg_local_refs<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
386386

387387
let lvalue = LvalueRef::alloca(bcx, arg_ty, &format!("arg{}", arg_index));
388388
for (i, &tupled_arg_ty) in tupled_arg_tys.iter().enumerate() {
389-
let dst = bcx.struct_gep(lvalue.llval, i);
389+
let (dst, _) = lvalue.trans_field_ptr(bcx, i);
390390
let arg = &mircx.fn_ty.args[idx];
391391
idx += 1;
392392
if common::type_is_fat_ptr(bcx.ccx, tupled_arg_ty) {

0 commit comments

Comments
 (0)
Please sign in to comment.