about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-04-19 11:25:40 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-04-19 11:25:40 -0700
commitd9d5eb82a7af56c60fe09aff5d73a2fb525d7f57 (patch)
tree0fae40ea2e09a6deefe3870768882c2852faa93c
parent6599b310f704f864b8c6eb48f972357785bf592b (diff)
downloadrust-d9d5eb82a7af56c60fe09aff5d73a2fb525d7f57.tar.gz
rust-d9d5eb82a7af56c60fe09aff5d73a2fb525d7f57.zip
rustc: Allow glue to be emitted even for scalar types; this is necessary to support compare glue
-rw-r--r--src/comp/middle/trans.rs71
1 files changed, 33 insertions, 38 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index a6c4568dd01..bb8ecd9c66d 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -1694,53 +1694,48 @@ fn make_generic_glue(@local_ctxt cx,
     auto bcx = new_top_block_ctxt(fcx);
     auto lltop = bcx.llbb;
 
-    if (!ty.type_is_scalar(t)) {
-
-        // Any nontrivial glue is with values passed *by alias*; this is a
-        // requirement since in many contexts glue is invoked indirectly and
-        // the caller has no idea if it's dealing with something that can be
-        // passed by value.
+    // Any nontrivial glue is with values passed *by alias*; this is a
+    // requirement since in many contexts glue is invoked indirectly and
+    // the caller has no idea if it's dealing with something that can be
+    // passed by value.
 
-        auto llty;
-        if (ty.type_has_dynamic_size(t)) {
-            llty = T_ptr(T_i8());
-        } else {
-            llty = T_ptr(type_of(cx.ccx, t));
-        }
+    auto llty;
+    if (ty.type_has_dynamic_size(t)) {
+        llty = T_ptr(T_i8());
+    } else {
+        llty = T_ptr(type_of(cx.ccx, t));
+    }
 
-        auto ty_param_count = _vec.len[uint](ty_params);
+    auto ty_param_count = _vec.len[uint](ty_params);
 
-        auto lltyparams = llvm.LLVMGetParam(llfn, 3u);
+    auto lltyparams = llvm.LLVMGetParam(llfn, 3u);
 
-        auto lltydescs = _vec.empty_mut[ValueRef]();
-        auto p = 0u;
-        while (p < ty_param_count) {
-            auto llparam = bcx.build.GEP(lltyparams, vec(C_int(p as int)));
-            llparam = bcx.build.Load(llparam);
-            _vec.grow_set[ValueRef](lltydescs, ty_params.(p), 0 as ValueRef,
-                                    llparam);
-            p += 1u;
-        }
-        bcx.fcx.lltydescs = _vec.freeze[ValueRef](lltydescs);
+    auto lltydescs = _vec.empty_mut[ValueRef]();
+    auto p = 0u;
+    while (p < ty_param_count) {
+        auto llparam = bcx.build.GEP(lltyparams, vec(C_int(p as int)));
+        llparam = bcx.build.Load(llparam);
+        _vec.grow_set[ValueRef](lltydescs, ty_params.(p), 0 as ValueRef,
+                                llparam);
+        p += 1u;
+    }
+    bcx.fcx.lltydescs = _vec.freeze[ValueRef](lltydescs);
 
-        auto llrawptr0 = llvm.LLVMGetParam(llfn, 4u);
-        auto llval0 = bcx.build.BitCast(llrawptr0, llty);
+    auto llrawptr0 = llvm.LLVMGetParam(llfn, 4u);
+    auto llval0 = bcx.build.BitCast(llrawptr0, llty);
 
-        alt (helper) {
-            case (mgghf_single(?single_fn)) {
-                single_fn(bcx, llval0, t);
-            }
-            case (mgghf_cmp) {
-                auto llrawptr1 = llvm.LLVMGetParam(llfn, 5u);
-                auto llval1 = bcx.build.BitCast(llrawptr0, llty);
+    alt (helper) {
+        case (mgghf_single(?single_fn)) {
+            single_fn(bcx, llval0, t);
+        }
+        case (mgghf_cmp) {
+            auto llrawptr1 = llvm.LLVMGetParam(llfn, 5u);
+            auto llval1 = bcx.build.BitCast(llrawptr0, llty);
 
-                auto llcmpval = llvm.LLVMGetParam(llfn, 6u);
+            auto llcmpval = llvm.LLVMGetParam(llfn, 6u);
 
-                make_cmp_glue(bcx, llval0, llval1, t, llcmpval);
-            }
+            make_cmp_glue(bcx, llval0, llval1, t, llcmpval);
         }
-    } else {
-        bcx.build.RetVoid();
     }
 
     // Tie up the llallocas -> lltop edge.