about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-04-18 14:10:13 -0700
committerBrian Anderson <banderson@mozilla.com>2013-04-18 14:14:17 -0700
commit8a6d6dd868371e2ffc035dc508fb255bb9cbc8a0 (patch)
treeee4eea7f7415001a271afc2cb67b87d9d793006c /src
parentb329f2fa82185c9e7c6bbbdf26270dd839618e9c (diff)
downloadrust-8a6d6dd868371e2ffc035dc508fb255bb9cbc8a0.tar.gz
rust-8a6d6dd868371e2ffc035dc508fb255bb9cbc8a0.zip
rustc: Fix struct returns on x86 mac for 8-byte structs
Mac appears to follow the same ABI as MSVC. This fixes one case
but leaves others broken, like windows.
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/trans/cabi_x86.rs10
-rw-r--r--src/test/run-pass/extern-pass-TwoU32s.rs2
-rw-r--r--src/test/run-pass/extern-return-TwoU32s.rs2
3 files changed, 5 insertions, 9 deletions
diff --git a/src/librustc/middle/trans/cabi_x86.rs b/src/librustc/middle/trans/cabi_x86.rs
index a549f912171..08b8c3db3ca 100644
--- a/src/librustc/middle/trans/cabi_x86.rs
+++ b/src/librustc/middle/trans/cabi_x86.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use driver::session::os_win32;
+use driver::session::{os_win32, os_macos};
 use core::option::*;
 use lib::llvm::*;
 use lib::llvm::llvm::*;
@@ -38,12 +38,12 @@ impl ABIInfo for X86_ABIInfo {
 
         // Rules for returning structs taken from
         // http://www.angelcode.com/dev/callconv/callconv.html
+        // Clang's ABI handling is in lib/CodeGen/TargetInfo.cpp
         let sret = {
             let returning_a_struct = unsafe { LLVMGetTypeKind(rty) == Struct && ret_def };
-            let big_struct = if self.ccx.sess.targ_cfg.os != os_win32 {
-                true
-            } else {
-                llsize_of_alloc(self.ccx, rty) > 8
+            let big_struct = match self.ccx.sess.targ_cfg.os {
+                os_win32 | os_macos => llsize_of_alloc(self.ccx, rty) > 8,
+                _ => true
             };
             returning_a_struct && big_struct
         };
diff --git a/src/test/run-pass/extern-pass-TwoU32s.rs b/src/test/run-pass/extern-pass-TwoU32s.rs
index db040b8407a..16d14a96cfe 100644
--- a/src/test/run-pass/extern-pass-TwoU32s.rs
+++ b/src/test/run-pass/extern-pass-TwoU32s.rs
@@ -11,8 +11,6 @@
 // Test a foreign function that accepts and returns a struct
 // by value.
 
-// xfail-macos Broken on mac i686
-
 #[deriving(Eq)]
 struct TwoU32s {
     one: u32, two: u32
diff --git a/src/test/run-pass/extern-return-TwoU32s.rs b/src/test/run-pass/extern-return-TwoU32s.rs
index 38e61ae6d49..9e374687855 100644
--- a/src/test/run-pass/extern-return-TwoU32s.rs
+++ b/src/test/run-pass/extern-return-TwoU32s.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// xfail-macos Broken on mac i686
-
 struct TwoU32s {
     one: u32, two: u32
 }