about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/comp/back/upcall.rs11
-rw-r--r--src/comp/metadata/creader.rs2
-rw-r--r--src/comp/middle/trans.rs68
-rw-r--r--src/comp/middle/trans_build.rs6
-rw-r--r--src/comp/middle/trans_common.rs2
-rw-r--r--src/rt/arch/i386/_context.S56
-rw-r--r--src/rt/intrinsics/intrinsics.i386.ll.in23
-rw-r--r--src/rt/intrinsics/intrinsics.x86_64.ll.in23
-rw-r--r--src/rt/rust_log.cpp2
9 files changed, 96 insertions, 97 deletions
diff --git a/src/comp/back/upcall.rs b/src/comp/back/upcall.rs
index 9d67aea59d9..cda0dcd7f31 100644
--- a/src/comp/back/upcall.rs
+++ b/src/comp/back/upcall.rs
@@ -48,6 +48,7 @@ fn declare_upcalls(targ_cfg: @session::config,
     let dv = bind decl(llmod, _, _, T_void());
 
     let int_t = T_int(targ_cfg);
+    let float_t = T_float(targ_cfg);
     let size_t = T_size_t(targ_cfg);
     let opaque_vec_t = T_opaque_vec(targ_cfg);
 
@@ -88,16 +89,16 @@ fn declare_upcalls(targ_cfg: @session::config,
               d("dynastack_alloc_2", [size_t, T_ptr(tydesc_type)],
                 T_ptr(T_i8())),
           dynastack_free: dv("dynastack_free", [T_ptr(T_i8())]),
-          alloc_c_stack: d("alloc_c_stack", [T_size_t()], T_ptr(T_i8())),
+          alloc_c_stack: d("alloc_c_stack", [size_t], T_ptr(T_i8())),
           call_c_stack: d("call_c_stack",
-                              [T_ptr(T_fn([], T_int())), T_ptr(T_i8())],
+                              [T_ptr(T_fn([], int_t)), T_ptr(T_i8())],
                               int_t),
           call_c_stack_i64: d("call_c_stack_i64",
-                              [T_ptr(T_fn([], T_int())), T_ptr(T_i8())],
+                              [T_ptr(T_fn([], int_t)), T_ptr(T_i8())],
                               T_i64()),
           call_c_stack_float: d("call_c_stack_float",
-                                [T_ptr(T_fn([], T_int())), T_ptr(T_i8())],
-                                T_float()),
+                                [T_ptr(T_fn([], int_t)), T_ptr(T_i8())],
+                                float_t),
           rust_personality: d("rust_personality", [], T_i32())
          };
 }
diff --git a/src/comp/metadata/creader.rs b/src/comp/metadata/creader.rs
index 9fac72e1ddb..2328c2efa93 100644
--- a/src/comp/metadata/creader.rs
+++ b/src/comp/metadata/creader.rs
@@ -169,7 +169,7 @@ fn find_library_crate_aux(sess: session::session,
 }
 
 fn get_metadata_section(sess: session::session,
-                        filename: str) -> option::t<@[u8]> {
+                        filename: str) -> option::t<@[u8]> unsafe {
     let mb = str::as_buf(filename, {|buf|
         llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
                                    });
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index f4009a929e3..cb1254d4729 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -226,13 +226,13 @@ fn type_of_tag(cx: @crate_ctxt, sp: span, did: ast::def_id, t: ty::t)
     let degen = std::vec::len(ty::tag_variants(cx.tcx, did)) == 1u;
     if check type_has_static_size(cx, t) {
         let size = static_size_of_tag(cx, sp, t);
-        if !degen { T_tag(cx.tn, size) }
-        else if size == 0u { T_struct([T_int()]) }
+        if !degen { T_tag(cx, size) }
+        else if size == 0u { T_struct([cx.int_type]) }
         else { T_array(T_i8(), size) }
     }
     else {
-        if degen { T_struct([T_int()]) }
-        else { T_opaque_tag(cx.tn) }
+        if degen { T_struct([cx.int_type]) }
+        else { T_opaque_tag(cx) }
     }
 }
 
@@ -3031,12 +3031,13 @@ fn trans_var(cx: @block_ctxt, sp: span, def: ast::def, id: ast::node_id)
             let lltagty = type_of_tag(ccx, sp, tid, tag_ty);
             let bcx = alloc_result.bcx;
             let lltagptr = PointerCast(bcx, lltagblob, T_ptr(lltagty));
-            let lldiscrimptr = GEP(bcx, lltagptr, [C_int(0), C_int(0)]);
+            let lldiscrimptr = GEP(bcx, lltagptr, [C_int(ccx, 0),
+                                                   C_int(ccx, 0)]);
             let d = if std::vec::len(ty::tag_variants(ccx.tcx, tid)) != 1u {
                 let lldiscrim_gv = lookup_discriminant(bcx.fcx.lcx, vid);
                 let lldiscrim = Load(bcx, lldiscrim_gv);
                 lldiscrim
-            } else { C_int(0) };
+            } else { C_int(ccx, 0) };
             Store(bcx, d, lldiscrimptr);
             ret lval_no_env(bcx, lltagptr, temporary);
           }
@@ -3914,7 +3915,8 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
     let i = 0u, n = vec::len(llargs);
     while i < n {
         let llarg = llargs[i].llval;
-        store_inbounds(bcx, llarg, llargbundle, [C_int(0), C_uint(i)]);
+        store_inbounds(bcx, llarg, llargbundle, [C_int(ccx, 0),
+                                                 C_uint(ccx, i)]);
         i += 1u;
     }
 
@@ -4449,8 +4451,8 @@ fn trans_log(lvl: int, cx: @block_ctxt, e: @ast::expr) -> @block_ctxt {
     let llvalptr = r.val;
     let llval_i8 = PointerCast(log_bcx, llvalptr, T_ptr(T_i8()));
 
-    Call(log_bcx, bcx_ccx(log_bcx).upcalls.log_type,
-         [lltydesc, llval_i8, C_int(lvl)]);
+    Call(log_bcx, ccx.upcalls.log_type,
+         [lltydesc, llval_i8, C_int(ccx, lvl)]);
 
     log_bcx = trans_block_cleanups(log_bcx, log_cx);
     Br(log_bcx, after_cx.llbb);
@@ -4514,7 +4516,7 @@ fn trans_fail_value(bcx: @block_ctxt, sp_opt: option::t<span>,
     }
     let V_str = PointerCast(bcx, V_fail_str, T_ptr(T_i8()));
     V_filename = PointerCast(bcx, V_filename, T_ptr(T_i8()));
-    let args = [V_str, V_filename, C_int(V_line)];
+    let args = [V_str, V_filename, C_int(ccx, V_line)];
     let bcx = invoke(bcx, bcx_ccx(bcx).upcalls._fail, args);
     Unreachable(bcx);
     ret bcx;
@@ -5518,7 +5520,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
         fn main_name() -> str { ret "main"; }
         #[cfg(target_os = "linux")]
         fn main_name() -> str { ret "main"; }
-        let llfty = T_fn([T_int(), T_int()], T_int());
+        let llfty = T_fn([ccx.int_type, ccx.int_type], ccx.int_type);
         let llfn = decl_cdecl_fn(ccx.llmod, main_name(), llfty);
         let llbb = str::as_buf("top", {|buf|
             llvm::LLVMAppendBasicBlock(llfn, buf)
@@ -5526,8 +5528,8 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
         let bld = *ccx.builder;
         llvm::LLVMPositionBuilderAtEnd(bld, llbb);
         let crate_map = ccx.crate_map;
-        let start_ty = T_fn([val_ty(rust_main), T_int(), T_int(),
-                             val_ty(crate_map)], T_int());
+        let start_ty = T_fn([val_ty(rust_main), ccx.int_type, ccx.int_type,
+                             val_ty(crate_map)], ccx.int_type);
         let start = str::as_buf("rust_start", {|buf|
             llvm::LLVMAddGlobal(ccx.llmod, start_ty, buf)
         });
@@ -6018,10 +6020,11 @@ fn create_module_map(ccx: @crate_ctxt) -> ValueRef {
                          lib::llvm::LLVMInternalLinkage as llvm::Linkage);
     let elts: [ValueRef] = [];
     ccx.module_data.items {|key, val|
-        let elt = C_struct([p2i(C_cstr(ccx, key)), p2i(val)]);
+        let elt = C_struct([p2i(ccx, C_cstr(ccx, key)),
+                            p2i(ccx, val)]);
         elts += [elt];
     };
-    let term = C_struct([C_int(0), C_int(0)]);
+    let term = C_struct([C_int(ccx, 0), C_int(ccx, 0)]);
     elts += [term];
     llvm::LLVMSetInitializer(map, C_array(elttype, elts));
     ret map;
@@ -6030,13 +6033,15 @@ fn create_module_map(ccx: @crate_ctxt) -> ValueRef {
 
 fn decl_crate_map(sess: session::session, mapname: str,
                   llmod: ModuleRef) -> ValueRef {
+    let targ_cfg = sess.get_targ_cfg();
+    let int_type = T_int(targ_cfg);
     let n_subcrates = 1;
     let cstore = sess.get_cstore();
     while cstore::have_crate_data(cstore, n_subcrates) { n_subcrates += 1; }
     if !sess.get_opts().library { mapname = "toplevel"; }
     let sym_name = "_rust_crate_map_" + mapname;
-    let arrtype = T_array(T_int(), n_subcrates as uint);
-    let maptype = T_struct([T_int(), arrtype]);
+    let arrtype = T_array(int_type, n_subcrates as uint);
+    let maptype = T_struct([int_type, arrtype]);
     let map = str::as_buf(sym_name, {|buf|
         llvm::LLVMAddGlobal(llmod, maptype, buf)
     });
@@ -6053,32 +6058,15 @@ fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) {
     while cstore::have_crate_data(cstore, i) {
         let nm = "_rust_crate_map_" + cstore::get_crate_data(cstore, i).name;
         let cr = str::as_buf(nm, {|buf|
-            llvm::LLVMAddGlobal(ccx.llmod, T_int(), buf)
+            llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type, buf)
         });
-        subcrates += [p2i(cr)];
+        subcrates += [p2i(ccx, cr)];
         i += 1;
     }
-    subcrates += [C_int(0)];
-    llvm::LLVMSetInitializer(map, C_struct([p2i(create_module_map(ccx)),
-                                            C_array(T_int(), subcrates)]));
     subcrates += [C_int(ccx, 0)];
-    let mapname;
-    if ccx.sess.get_opts().library {
-        mapname = ccx.link_meta.name;
-    } else { mapname = "toplevel"; }
-    let sym_name = "_rust_crate_map_" + mapname;
-    let arrtype = T_array(ccx.int_type, std::vec::len::<ValueRef>(subcrates));
-    let maptype = T_struct([ccx.int_type, arrtype]);
-    let map =
-        str::as_buf(sym_name,
-                    {|buf| llvm::LLVMAddGlobal(ccx.llmod, maptype, buf) });
-    llvm::LLVMSetLinkage(map,
-                         lib::llvm::LLVMExternalLinkage as llvm::Linkage);
-    llvm::LLVMSetInitializer(map,
-                             C_struct([p2i(ccx, create_module_map(ccx)),
-                                       C_array(ccx.int_type, subcrates)]));
-    ret map;
->>>>>>> work on making the size of ints depend on the target arch
+    llvm::LLVMSetInitializer(map, C_struct(
+        [p2i(ccx, create_module_map(ccx)),
+         C_array(ccx.int_type, subcrates)]));
 }
 
 fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) {
@@ -6138,7 +6126,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
     let task_type = T_task(targ_cfg);
     let taskptr_type = T_ptr(task_type);
     tn.associate("taskptr", taskptr_type);
-    let tydesc_type = T_tydesc(targ_cfg, taskptr_type);
+    let tydesc_type = T_tydesc(targ_cfg);
     tn.associate("tydesc", tydesc_type);
     let hasher = ty::hash_ty;
     let eqer = ty::eq_ty;
diff --git a/src/comp/middle/trans_build.rs b/src/comp/middle/trans_build.rs
index 68cf33398ed..c2f5fbedaa2 100644
--- a/src/comp/middle/trans_build.rs
+++ b/src/comp/middle/trans_build.rs
@@ -497,7 +497,7 @@ fn _UndefReturn(cx: @block_ctxt, Fn: ValueRef) -> ValueRef {
 }
 
 fn Call(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef]) -> ValueRef {
-    if cx.unreachable { ret _UndefReturn(Fn); }
+    if cx.unreachable { ret _UndefReturn(cx, Fn); }
     unsafe {
         ret llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args),
                                 vec::len(Args), noname());
@@ -505,7 +505,7 @@ fn Call(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef]) -> ValueRef {
 }
 
 fn FastCall(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef]) -> ValueRef {
-    if cx.unreachable { ret _UndefReturn(Fn); }
+    if cx.unreachable { ret _UndefReturn(cx, Fn); }
     unsafe {
         let v = llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args),
                                     vec::len(Args), noname());
@@ -516,7 +516,7 @@ fn FastCall(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef]) -> ValueRef {
 
 fn CallWithConv(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef], Conv: uint)
    -> ValueRef {
-    if cx.unreachable { ret _UndefReturn(Fn); }
+    if cx.unreachable { ret _UndefReturn(cx, Fn); }
     unsafe {
         let v = llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args),
                                     vec::len(Args), noname());
diff --git a/src/comp/middle/trans_common.rs b/src/comp/middle/trans_common.rs
index 8e289d756a3..4a85d52e90d 100644
--- a/src/comp/middle/trans_common.rs
+++ b/src/comp/middle/trans_common.rs
@@ -576,7 +576,7 @@ fn T_task(targ_cfg: @session::config) -> TypeRef {
     ret t;
 }
 
-fn T_tydesc_field(cx: @crate_ctxt, field: int) -> TypeRef {
+fn T_tydesc_field(cx: @crate_ctxt, field: int) -> TypeRef unsafe {
     // Bit of a kludge: pick the fn typeref out of the tydesc..
 
     let tydesc_elts: [TypeRef] =
diff --git a/src/rt/arch/i386/_context.S b/src/rt/arch/i386/_context.S
index faee99284a5..b892342ee31 100644
--- a/src/rt/arch/i386/_context.S
+++ b/src/rt/arch/i386/_context.S
@@ -20,19 +20,19 @@ The registers_t variable is in (%esp)
 swap_registers:
     // save the old context
     movl 4(%esp), %eax
-	//movl %eax, 0(%eax)
-	movl %ebx, 4(%eax)
-	//movl %ecx, 8(%eax)
-	//movl %edx, 12(%eax)
-	movl %ebp, 16(%eax)
-	movl %esi, 20(%eax)
-	movl %edi, 24(%eax)
-	//movl %cs, 32(%eax)
-	//movl %ds, 34(%eax)
-	//movl %ss, 36(%eax)
-	//movl %es, 38(%eax)
-	//movl %fs, 40(%eax)
-	//movl %gs, 42(%eax)
+    //movl %eax, 0(%eax)
+    movl %ebx, 4(%eax)
+    //movl %ecx, 8(%eax)
+    //movl %edx, 12(%eax)
+    movl %ebp, 16(%eax)
+    movl %esi, 20(%eax)
+    movl %edi, 24(%eax)
+    //movl %cs, 32(%eax)
+    //movl %ds, 34(%eax)
+    //movl %ss, 36(%eax)
+    //movl %es, 38(%eax)
+    //movl %fs, 40(%eax)
+    //movl %gs, 42(%eax)
 
         // save the flags
         pushf
@@ -48,20 +48,20 @@ swap_registers:
     // restore the new context
     movl 4(%esp), %eax
 
-	movl 4(%eax), %ebx
-	// save ecx for later...
-	//movl 12(%eax), %edx
-	movl 16(%eax), %ebp
-	movl 20(%eax), %esi
-	movl 24(%eax), %edi
-	movl 28(%eax), %esp
-	// We can't actually change this...
-	//movl 32(%eax), %cs
-	//movl 34(%eax), %ds
-	//movl 36(%eax), %ss
-	//movl 38(%eax), %es
-	//movl 40(%eax), %fs
-	//movl 42(%eax), %gs
+    movl 4(%eax), %ebx
+    // save ecx for later...
+    //movl 12(%eax), %edx
+    movl 16(%eax), %ebp
+    movl 20(%eax), %esi
+    movl 24(%eax), %edi
+    movl 28(%eax), %esp
+    // We can't actually change this...
+    //movl 32(%eax), %cs
+    //movl 34(%eax), %ds
+    //movl 36(%eax), %ss
+    //movl 38(%eax), %es
+    //movl 40(%eax), %fs
+    //movl 42(%eax), %gs
 
         // restore the flags
         movl 44(%eax), %ecx
@@ -70,7 +70,7 @@ swap_registers:
 
     // ok, now we can restore ecx
     //movl 8(%eax), %ecx
-	
+
     // Return!
     jmp *48(%eax)
 
diff --git a/src/rt/intrinsics/intrinsics.i386.ll.in b/src/rt/intrinsics/intrinsics.i386.ll.in
index 93cc32fe995..971314dba56 100644
--- a/src/rt/intrinsics/intrinsics.i386.ll.in
+++ b/src/rt/intrinsics/intrinsics.i386.ll.in
@@ -53,7 +53,7 @@ target triple = "@CFG_TARGET_TRIPLE@"
 %struct.rust_vec = type { i32, i32, [0 x i8] }
 %"struct.std::_Rb_tree<void *, std::pair<void *const, const type_desc *>, std::_Select1st<std::pair<void *const, const type_desc *> >, std::less<void *>, std::allocator<std::pair<void *const, const type_desc *> > >::_Rb_tree_impl" = type { %struct.rust_cond, %"struct.std::_Rb_tree_node_base", i32 }
 %"struct.std::_Rb_tree_node_base" = type { i32, %"struct.std::_Rb_tree_node_base"*, %"struct.std::_Rb_tree_node_base"*, %"struct.std::_Rb_tree_node_base"* }
-%struct.type_desc = type { %struct.type_desc**, i32, i32, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, i8*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, i32, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*, i8*, i8)*, i8*, %struct.rust_shape_tables*, i32, i32, %struct.UT_hash_handle, i32, [0 x %struct.type_desc*] }
+%struct.type_desc = type { %struct.type_desc**, i32, i32, void (i8*, i8*, %struct.type_desc**, i8*)*, void (i8*, i8*, %struct.type_desc**, i8*)*, void (i8*, i8*, %struct.type_desc**, i8*)*, i8*, void (i8*, i8*, %struct.type_desc**, i8*)*, void (i8*, i8*, %struct.type_desc**, i8*)*, i32, void (i8*, i8*, %struct.type_desc**, i8*, i8*, i8)*, i8*, %struct.rust_shape_tables*, i32, i32, %struct.UT_hash_handle, i32, [0 x %struct.type_desc*] }
 
 @.str = private unnamed_addr constant [42 x i8] c"attempt to cast values of differing sizes\00"
 @.str1 = private unnamed_addr constant [33 x i8] c"src/rt/intrinsics/intrinsics.cpp\00"
@@ -78,7 +78,7 @@ define void @rust_intrinsic_ptr_offset(%struct.rust_task* nocapture %task, i8**
   ret void
 }
 
-define void @rust_intrinsic_cast(%struct.rust_task* %task, i8* nocapture %retptr, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) {
+define void @rust_intrinsic_cast(%struct.rust_task* nocapture %task, i8* nocapture %retptr, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) {
   %1 = getelementptr inbounds %struct.type_desc* %t1, i32 0, i32 1
   %2 = load i32* %1, align 4
   %3 = getelementptr inbounds %struct.type_desc* %t2, i32 0, i32 1
@@ -87,7 +87,7 @@ define void @rust_intrinsic_cast(%struct.rust_task* %task, i8* nocapture %retptr
   br i1 %5, label %7, label %6
 
 ; <label>:6                                       ; preds = %0
-  tail call void @upcall_fail(%struct.rust_task* %task, i8* getelementptr inbounds ([42 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([33 x i8]* @.str1, i32 0, i32 0), i32 32)
+  tail call void @upcall_fail(i8* getelementptr inbounds ([42 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([33 x i8]* @.str1, i32 0, i32 0), i32 32)
   br label %8
 
 ; <label>:7                                       ; preds = %0
@@ -98,7 +98,7 @@ define void @rust_intrinsic_cast(%struct.rust_task* %task, i8* nocapture %retptr
   ret void
 }
 
-declare void @upcall_fail(%struct.rust_task*, i8*, i8*, i32)
+declare void @upcall_fail(i8*, i8*, i32)
 
 declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
 
@@ -107,11 +107,16 @@ define void @rust_intrinsic_addr_of(%struct.rust_task* nocapture %task, i8** noc
   ret void
 }
 
-define void @rust_intrinsic_recv(%struct.rust_task* %task, i8** %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
-  %1 = bitcast %struct.rust_task* %task to i8*
-  %2 = bitcast i8** %retptr to i32*
-  tail call void @port_recv(i8* %1, i32* %2, %class.rust_port* %port)
+define void @rust_intrinsic_recv(%struct.rust_task* nocapture %task, i8** %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
+  %1 = bitcast i8** %retptr to i32*
+  tail call void @port_recv(i32* %1, %class.rust_port* %port)
   ret void
 }
 
-declare void @port_recv(i8*, i32*, %class.rust_port*)
+declare void @port_recv(i32*, %class.rust_port*)
+
+define void @rust_intrinsic_get_type_desc(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* %ty) nounwind {
+  %ty.c = bitcast %struct.type_desc* %ty to i8*
+  store i8* %ty.c, i8** %retptr, align 4
+  ret void
+}
diff --git a/src/rt/intrinsics/intrinsics.x86_64.ll.in b/src/rt/intrinsics/intrinsics.x86_64.ll.in
index 50e2e9178d4..77c05e1e1e5 100644
--- a/src/rt/intrinsics/intrinsics.x86_64.ll.in
+++ b/src/rt/intrinsics/intrinsics.x86_64.ll.in
@@ -53,7 +53,7 @@ target triple = "@CFG_TARGET_TRIPLE@"
 %"struct.std::_Rb_tree<void *, std::pair<void *const, const type_desc *>, std::_Select1st<std::pair<void *const, const type_desc *> >, std::less<void *>, std::allocator<std::pair<void *const, const type_desc *> > >::_Rb_tree_impl" = type { %struct.rust_cond, %"struct.std::_Rb_tree_node_base", i64 }
 %"struct.std::_Rb_tree_node_base" = type { i32, %"struct.std::_Rb_tree_node_base"*, %"struct.std::_Rb_tree_node_base"*, %"struct.std::_Rb_tree_node_base"* }
 %struct.stk_seg = type { i32, i64, [0 x i8] }
-%struct.type_desc = type { %struct.type_desc**, i64, i64, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, i8*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, i64, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*, i8*, i8)*, i8*, %struct.rust_shape_tables*, i64, i64, %struct.UT_hash_handle, i64, [0 x %struct.type_desc*] }
+%struct.type_desc = type { %struct.type_desc**, i64, i64, void (i8*, i8*, %struct.type_desc**, i8*)*, void (i8*, i8*, %struct.type_desc**, i8*)*, void (i8*, i8*, %struct.type_desc**, i8*)*, i8*, void (i8*, i8*, %struct.type_desc**, i8*)*, void (i8*, i8*, %struct.type_desc**, i8*)*, i64, void (i8*, i8*, %struct.type_desc**, i8*, i8*, i8)*, i8*, %struct.rust_shape_tables*, i64, i64, %struct.UT_hash_handle, i64, [0 x %struct.type_desc*] }
 
 @.str = private unnamed_addr constant [42 x i8] c"attempt to cast values of differing sizes\00"
 @.str1 = private unnamed_addr constant [33 x i8] c"src/rt/intrinsics/intrinsics.cpp\00"
@@ -78,7 +78,7 @@ define void @rust_intrinsic_ptr_offset(%struct.rust_task* nocapture %task, i8**
   ret void
 }
 
-define void @rust_intrinsic_cast(%struct.rust_task* %task, i8* nocapture %retptr, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) {
+define void @rust_intrinsic_cast(%struct.rust_task* nocapture %task, i8* nocapture %retptr, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) {
   %1 = getelementptr inbounds %struct.type_desc* %t1, i64 0, i32 1
   %2 = load i64* %1, align 8
   %3 = getelementptr inbounds %struct.type_desc* %t2, i64 0, i32 1
@@ -87,7 +87,7 @@ define void @rust_intrinsic_cast(%struct.rust_task* %task, i8* nocapture %retptr
   br i1 %5, label %7, label %6
 
 ; <label>:6                                       ; preds = %0
-  tail call void @upcall_fail(%struct.rust_task* %task, i8* getelementptr inbounds ([42 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8]* @.str1, i64 0, i64 0), i64 32)
+  tail call void @upcall_fail(i8* getelementptr inbounds ([42 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8]* @.str1, i64 0, i64 0), i64 32)
   br label %8
 
 ; <label>:7                                       ; preds = %0
@@ -98,7 +98,7 @@ define void @rust_intrinsic_cast(%struct.rust_task* %task, i8* nocapture %retptr
   ret void
 }
 
-declare void @upcall_fail(%struct.rust_task*, i8*, i8*, i64)
+declare void @upcall_fail(i8*, i8*, i64)
 
 declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
 
@@ -107,11 +107,16 @@ define void @rust_intrinsic_addr_of(%struct.rust_task* nocapture %task, i8** noc
   ret void
 }
 
-define void @rust_intrinsic_recv(%struct.rust_task* %task, i8** %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
-  %1 = bitcast %struct.rust_task* %task to i8*
-  %2 = bitcast i8** %retptr to i64*
-  tail call void @port_recv(i8* %1, i64* %2, %class.rust_port* %port)
+define void @rust_intrinsic_recv(%struct.rust_task* nocapture %task, i8** %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
+  %1 = bitcast i8** %retptr to i64*
+  tail call void @port_recv(i64* %1, %class.rust_port* %port)
   ret void
 }
 
-declare void @port_recv(i8*, i64*, %class.rust_port*)
+declare void @port_recv(i64*, %class.rust_port*)
+
+define void @rust_intrinsic_get_type_desc(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* %ty) nounwind {
+  %ty.c = bitcast %struct.type_desc* %ty to i8*
+  store i8* %ty.c, i8** %retptr, align 8
+  ret void
+}
diff --git a/src/rt/rust_log.cpp b/src/rt/rust_log.cpp
index e0d799f7caa..270b716679d 100644
--- a/src/rt/rust_log.cpp
+++ b/src/rt/rust_log.cpp
@@ -42,7 +42,7 @@ hash(uintptr_t ptr) {
     ptr = ptr ^ (ptr >> 14);
     ptr = (ptr + (ptr << 2)) + (ptr << 4); // ptr * 21
     ptr = ptr ^ (ptr >> 28);
-    ptr = ptr + (ptr << 31);    
+    ptr = ptr + (ptr << 31);
 #   else
 #   error "hash() not defined for this pointer size"
 #   endif