Skip to content

Commit e8e72ac

Browse files
jldcatamorphism
authored andcommitted
---
yaml --- r: 38447 b: refs/heads/try c: 1b4f3fa h: refs/heads/master i: 38445: 2698ce8 38443: c991034 38439: e60afb1 38431: 7dafbb8 v: v3
1 parent a32a3de commit e8e72ac

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
@@ -2,7 +2,7 @@
22
refs/heads/master: 09bb07bed9166105ea961a42b5fff7739ae0d2e9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
5-
refs/heads/try: cd01ecfe1329d90584d35d775f2a645abba61811
5+
refs/heads/try: 1b4f3fad1e6036b3d7cb17cc80ac1c204e1f11a2
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278

branches/try/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)