Skip to content

Commit

Permalink
Fix handling of closure arguments
Browse files Browse the repository at this point in the history
Those did not take tuple reordering into account, causing majority of the compiler test suite to
fail.
  • Loading branch information
nagisa committed Apr 11, 2017
1 parent d821e98 commit a384f13
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/librustc/ty/layout.rs
Expand Up @@ -598,7 +598,7 @@ impl<'a, 'gcx, 'tcx> Struct {
// In addition, code in trans assume that 2-element structs can become pairs.
// It's easier to just short-circuit here.
let can_optimize = (fields.len() > 2 || StructKind::EnumVariant == kind)
&& ! (repr.c || repr.packed || repr.linear || repr.simd);
&& !(repr.c || repr.packed || repr.linear || repr.simd);

let (optimize, sort_ascending) = match kind {
StructKind::AlwaysSizedUnivariant => (can_optimize, false),
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/ty/mod.rs
Expand Up @@ -1419,7 +1419,8 @@ impl_stable_hash_for!(struct ReprOptions {
c,
packed,
simd,
int
int,
linear
});

impl ReprOptions {
Expand Down
9 changes: 5 additions & 4 deletions src/librustc_trans/intrinsic.rs
Expand Up @@ -16,7 +16,7 @@ use llvm;
use llvm::{ValueRef};
use abi::{Abi, FnType};
use adt;
use mir::lvalue::LvalueRef;
use mir::lvalue::{LvalueRef, Alignment};
use base::*;
use common::*;
use declare;
Expand All @@ -36,8 +36,6 @@ use syntax_pos::Span;
use std::cmp::Ordering;
use std::iter;

use mir::lvalue::Alignment;

fn get_simple_intrinsic(ccx: &CrateContext, name: &str) -> Option<ValueRef> {
let llvm_name = match name {
"sqrtf32" => "llvm.sqrt.f32",
Expand Down Expand Up @@ -622,7 +620,10 @@ pub fn trans_intrinsic_call<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,

for i in 0..elems.len() {
let val = bcx.extract_value(val, i);
bcx.store(val, bcx.struct_gep(llresult, i), None);
let lval = LvalueRef::new_sized_ty(llresult, ret_ty,
Alignment::AbiAligned);
let (dest, _) = lval.trans_field_ptr(bcx, i);
bcx.store(val, dest, None);
}
C_nil(ccx)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/mir/mod.rs
Expand Up @@ -386,7 +386,7 @@ fn arg_local_refs<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,

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

0 comments on commit a384f13

Please sign in to comment.