Skip to content

Commit 6d554db

Browse files
jldcatamorphism
authored andcommitted
---
yaml --- r: 39832 b: refs/heads/incoming c: 1b4f3fa h: refs/heads/master v: v3
1 parent 9eece94 commit 6d554db

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
9-
refs/heads/incoming: cd01ecfe1329d90584d35d775f2a645abba61811
9+
refs/heads/incoming: 1b4f3fad1e6036b3d7cb17cc80ac1c204e1f11a2
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/librustc/middle/trans/foreign.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
9494
fn struct_tys(ty: TypeRef) -> ~[TypeRef] {
9595
unsafe {
9696
let n = llvm::LLVMCountStructElementTypes(ty);
97+
if (n == 0) {
98+
return ~[];
99+
}
97100
let mut elts = vec::from_elem(n as uint, ptr::null());
98101
llvm::LLVMGetStructElementTypes(ty,
99102
ptr::to_mut_unsafe_ptr(&mut elts[0]));
@@ -111,7 +114,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
111114
Float => 4,
112115
Double => 8,
113116
Struct => {
114-
do vec::foldl(0, struct_tys(ty)) |a, t| {
117+
do vec::foldl(1, struct_tys(ty)) |a, t| {
115118
uint::max(a, ty_align(*t))
116119
}
117120
}
@@ -184,15 +187,11 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
184187
fn classify_struct(tys: &[TypeRef],
185188
cls: &[mut x86_64_reg_class], i: uint,
186189
off: uint) {
187-
if vec::is_empty(tys) {
188-
classify(T_i64(), cls, i, off);
189-
} else {
190-
let mut field_off = off;
191-
for vec::each(tys) |ty| {
192-
field_off = align(field_off, *ty);
193-
classify(*ty, cls, i, field_off);
194-
field_off += ty_size(*ty);
195-
}
190+
let mut field_off = off;
191+
for vec::each(tys) |ty| {
192+
field_off = align(field_off, *ty);
193+
classify(*ty, cls, i, field_off);
194+
field_off += ty_size(*ty);
196195
}
197196
}
198197

@@ -378,13 +377,14 @@ fn x86_64_tys(atys: &[TypeRef],
378377
}
379378

380379
fn is_pass_byval(cls: &[x86_64_reg_class]) -> bool {
381-
return cls[0] == memory_class ||
382-
cls[0] == x87_class ||
383-
cls[0] == complex_x87_class;
380+
return cls.len() > 0 &&
381+
(cls[0] == memory_class ||
382+
cls[0] == x87_class ||
383+
cls[0] == complex_x87_class);
384384
}
385385

386386
fn is_ret_bysret(cls: &[x86_64_reg_class]) -> bool {
387-
return cls[0] == memory_class;
387+
return cls.len() > 0 && cls[0] == memory_class;
388388
}
389389

390390
fn x86_64_ty(ty: TypeRef,

0 commit comments

Comments
 (0)