diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-03-01 10:36:22 -0800 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-03-02 06:47:25 -0800 |
| commit | def72bda47977b3bc36143eba9692bff12a8303c (patch) | |
| tree | 20dc1277106ddb56ded43fec53318b17c51baee1 /src/rt | |
| parent | 12c68bcd6df325cc369adce018c07dfe3e2b767a (diff) | |
| download | rust-def72bda47977b3bc36143eba9692bff12a8303c.tar.gz rust-def72bda47977b3bc36143eba9692bff12a8303c.zip | |
retool inline encoding to handle methods, fix tests
Diffstat (limited to 'src/rt')
| -rw-r--r-- | src/rt/intrinsics/intrinsics.cpp | 6 | ||||
| -rw-r--r-- | src/rt/intrinsics/intrinsics.i386.ll.in | 338 | ||||
| -rw-r--r-- | src/rt/intrinsics/intrinsics.x86_64.ll.in | 361 | ||||
| -rw-r--r-- | src/rt/rust_builtin.cpp | 5 | ||||
| -rw-r--r-- | src/rt/rustrt.def.in | 1 |
5 files changed, 351 insertions, 360 deletions
diff --git a/src/rt/intrinsics/intrinsics.cpp b/src/rt/intrinsics/intrinsics.cpp index 04fb683eb75..d36bdf87675 100644 --- a/src/rt/intrinsics/intrinsics.cpp +++ b/src/rt/intrinsics/intrinsics.cpp @@ -166,3 +166,9 @@ upcall_vec_push(rust_vec** vp, type_desc* elt_ty, void* elt) { upcall_intrinsic_vec_push(vp, elt_ty, elt); } + +extern "C" CDECL void +rust_intrinsic_frame_address(void **p, unsigned n) { + *p = __builtin_frame_address(n); +} + diff --git a/src/rt/intrinsics/intrinsics.i386.ll.in b/src/rt/intrinsics/intrinsics.i386.ll.in index d8373cc0b10..a03bed03118 100644 --- a/src/rt/intrinsics/intrinsics.i386.ll.in +++ b/src/rt/intrinsics/intrinsics.i386.ll.in @@ -1,125 +1,114 @@ ; ModuleID = 'src/rt/intrinsics/intrinsics.cpp' -; target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128" +; target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32" target triple = "@CFG_TARGET_TRIPLE@" -%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, i8*, i8*, %struct.rust_shape_tables*, i32, i32, %struct.UT_hash_handle, i32, [0 x %struct.type_desc*] } -%struct.rust_shape_tables = type { i8*, i8* } +%0 = type { i32, %struct.rust_task**, i32 } +%1 = type { %"struct.hash_map<long, rust_task *>::map_entry"* } +%class.array_list = type { i32, %"struct.memory_region::alloc_header"**, i32 } +%class.boxed_region = type { %class.memory_region*, %struct.rust_opaque_box* } +%class.circular_buffer = type { %class.rust_kernel*, i32, i32, i32, i32, i8* } +%class.context = type { %struct.registers_t, %class.context*, [12 x i8] } +%"class.debug::task_debug_info" = type { %"class.std::map" } +%class.hash_map = type { %"struct.hash_map<long, rust_port *>::map_entry"* } +%class.indexed_list = type { i32 (...)**, %0 } +%class.lock_and_signal = type { i32 (...)**, %struct._opaque_pthread_cond_t, %struct._opaque_pthread_mutex_t, %struct._opaque_pthread_t* } +%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %class.array_list, i8, i8, %class.lock_and_signal } +%class.rust_crate_cache = type { %struct.type_desc*, %struct.rust_hashable_dict*, %struct.rust_task_thread*, i32 } +%class.rust_kernel = type { %class.memory_region, %class.rust_log, %class.rust_srv*, %class.lock_and_signal, i32, i32, %1, %class.lock_and_signal, i32, %class.lock_and_signal, i32, %"class.std::map", %"class.std::vector", %struct.rust_env* } +%class.rust_log = type { i32 (...)**, %class.rust_srv*, %struct.rust_task_thread*, i8 } +%class.rust_obstack = type { %struct.rust_obstack_chunk*, %struct.rust_task* } +%class.rust_port = type { i32, i32, %class.rust_kernel*, %struct.rust_task*, i32, %class.circular_buffer, %class.lock_and_signal } +%class.rust_port_selector = type { %class.rust_port**, i32, %class.lock_and_signal } +%class.rust_scheduler = type opaque +%class.rust_srv = type { i32 (...)**, %struct.rust_env*, %class.memory_region } +%class.rust_task_list = type { %class.indexed_list, %struct.rust_task_thread*, i8* } +%class.rust_thread = type { i32 (...)**, %struct._opaque_pthread_t*, i32 } +%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<long, std::pair<const long, rust_scheduler *>, std::_Select1st<std::pair<const long, rust_scheduler *> >, std::less<long>, std::allocator<std::pair<const long, rust_scheduler *> > >::_Rb_tree_impl" } +%"class.std::map" = type { %"class.std::_Rb_tree" } +%"class.std::vector" = type { %"struct.std::_Vector_base" } +%struct.UT_hash_bucket = type { %struct.UT_hash_handle*, i32, i32 } %struct.UT_hash_handle = type { %struct.UT_hash_table*, i8*, i8*, %struct.UT_hash_handle*, %struct.UT_hash_handle*, i8*, i32, i32 } %struct.UT_hash_table = type { %struct.UT_hash_bucket*, i32, i32, i32, %struct.UT_hash_handle*, i32, i32, i32, i32, i32 } -%struct.UT_hash_bucket = type { %struct.UT_hash_handle*, i32, i32 } -%struct.rust_vec = type { i32, i32, [0 x i8] } -%struct.rust_fn = type { i32*, %struct.rust_box* } -%struct.rust_box = type opaque -%struct.rust_task = type { i32, i32, i8, %struct.chan_handle, [12 x i8], %class.context, %struct.stk_seg*, i32, %class.rust_scheduler*, %struct.rust_task_thread*, %class.rust_crate_cache*, %class.rust_kernel*, i8*, %class.rust_task_list*, %struct.rust_cond*, i8*, %struct.rust_task*, i32, i32, i32*, %class.memory_region, %class.boxed_region, i8, i8, %class.lock_and_signal, %class.hash_map.3, %class.rust_obstack, i32, %"class.debug::task_debug_info", i32, i8, i8, %struct.stk_seg*, i32, i32, %class.rust_port_selector, [8 x i8] } +%struct.__darwin_pthread_handler_rec = type { void (i8*)*, i8*, %struct.__darwin_pthread_handler_rec* } +%struct._opaque_pthread_attr_t = type { i32, [36 x i8] } +%struct._opaque_pthread_cond_t = type { i32, [24 x i8] } +%struct._opaque_pthread_mutex_t = type { i32, [40 x i8] } +%struct._opaque_pthread_t = type { i32, %struct.__darwin_pthread_handler_rec*, [596 x i8] } %struct.chan_handle = type { i32, i32 } -%class.context = type { %struct.registers_t, %class.context*, [12 x i8] } +%"struct.hash_map<long, rust_port *>::map_entry" = type opaque +%"struct.hash_map<long, rust_task *>::map_entry" = type opaque +%"struct.memory_region::alloc_header" = type { i8 } +%struct.randctx = type { i32, [256 x i32], [256 x i32], i32, i32, i32 } %struct.registers_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i16, i16, i32, i32, [12 x i8] } -%struct.stk_seg = type { %struct.stk_seg*, %struct.stk_seg*, i32, i32, i32, i32, [0 x i8] } -%class.rust_scheduler = type opaque -%struct.rust_task_thread = type { %class.rust_thread, i32, %class.rust_log, i32, %class.rust_srv*, i8*, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_crate_cache, %struct.randctx, %class.rust_kernel*, %class.rust_scheduler*, i32, i32, %class.lock_and_signal, i32, %union.pthread_attr_t, %struct.rust_env*, [8 x i8], %class.context, i8, %struct.stk_seg*, %struct.stk_seg*, [4 x i8] } -%class.rust_thread = type { i32 (...)**, i32, i32 } -%class.rust_log = type { i32 (...)**, %class.rust_srv*, %struct.rust_task_thread*, i8 } -%class.rust_srv = type { i32 (...)**, %struct.rust_env*, %class.memory_region } +%struct.rust_box = type opaque %struct.rust_env = type { i32, i32, i32, i8*, i8, i8, i8* } -%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %class.array_list, i8, i8, %class.lock_and_signal } -%class.array_list = type { i32, %"struct.memory_region::alloc_header"**, i32 } -%"struct.memory_region::alloc_header" = type { i8 } -%class.lock_and_signal = type { i32 (...)**, %union.pthread_cond_t, %union.pthread_mutex_t, i32 } -%union.pthread_cond_t = type { %struct.anon, [4 x i8] } -%struct.anon = type { i32, i32, i64, i64, i64, i8*, i32, i32 } -%union.pthread_mutex_t = type { %"struct.<anonymous union>::__pthread_mutex_s" } -%"struct.<anonymous union>::__pthread_mutex_s" = type { i32, i32, i32, i32, i32, %union.anon } -%union.anon = type { i32 } -%class.rust_task_list = type { %class.indexed_list, %struct.rust_task_thread*, i8* } -%class.indexed_list = type { i32 (...)**, %class.array_list.1 } -%class.array_list.1 = type { i32, %struct.rust_task**, i32 } -%class.rust_crate_cache = type { %struct.type_desc*, %struct.rust_hashable_dict*, %struct.rust_task_thread*, i32 } +%struct.rust_fn = type { i32*, %struct.rust_box* } %struct.rust_hashable_dict = type { %struct.UT_hash_handle, [0 x i8*] } -%struct.randctx = type { i32, [256 x i32], [256 x i32], i32, i32, i32 } -%class.rust_kernel = type { %class.memory_region, %class.rust_log, %class.rust_srv*, %class.lock_and_signal, i32, i32, %class.hash_map, %class.lock_and_signal, i32, %class.lock_and_signal, i32, i32, %"class.std::map", %struct.rust_env* } -%class.hash_map = type { %"struct.hash_map<int, rust_task *>::map_entry"* } -%"struct.hash_map<int, rust_task *>::map_entry" = type opaque -%"class.std::map" = type { %"class.std::_Rb_tree" } -%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, std::pair<const int, rust_scheduler *>, std::_Select1st<std::pair<const int, rust_scheduler *> >, std::less<int>, std::allocator<std::pair<const int, rust_scheduler *> > >::_Rb_tree_impl" } -%"struct.std::_Rb_tree<int, std::pair<const int, rust_scheduler *>, std::_Select1st<std::pair<const int, rust_scheduler *> >, std::less<int>, std::allocator<std::pair<const int, rust_scheduler *> > >::_Rb_tree_impl" = type { %"struct.std::less", %"struct.std::_Rb_tree_node_base", i32 } -%"struct.std::less" = type { i8 } -%"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"* } -%union.pthread_attr_t = type { i32, [32 x i8] } -%struct.rust_cond = type { i8 } -%class.boxed_region = type { %class.memory_region*, %struct.rust_opaque_box* } -%struct.rust_opaque_box = type { i32, %struct.type_desc*, %struct.rust_opaque_box*, %struct.rust_opaque_box* } -%class.hash_map.3 = type { %"struct.hash_map<int, rust_port *>::map_entry"* } -%"struct.hash_map<int, rust_port *>::map_entry" = type opaque -%class.rust_obstack = type { %struct.rust_obstack_chunk*, %struct.rust_task* } %struct.rust_obstack_chunk = type { %struct.rust_obstack_chunk*, i32, i32, i32, [0 x i8] } -%"class.debug::task_debug_info" = type { %"class.std::map.4" } -%"class.std::map.4" = type { %"class.std::_Rb_tree.5" } -%"class.std::_Rb_tree.5" = type { %"struct.std::_Rb_tree<void *, std::pair<void *const, std::basic_string<char> >, std::_Select1st<std::pair<void *const, std::basic_string<char> > >, std::less<void *>, std::allocator<std::pair<void *const, std::basic_string<char> > > >::_Rb_tree_impl" } -%"struct.std::_Rb_tree<void *, std::pair<void *const, std::basic_string<char> >, std::_Select1st<std::pair<void *const, std::basic_string<char> > >, std::less<void *>, std::allocator<std::pair<void *const, std::basic_string<char> > > >::_Rb_tree_impl" = type { %"struct.std::less.9", %"struct.std::_Rb_tree_node_base", i32 } -%"struct.std::less.9" = type { i8 } -%class.rust_port_selector = type { %class.rust_port**, i32, %class.lock_and_signal } -%class.rust_port = type { i32, i32, %class.rust_kernel*, %struct.rust_task*, i32, %class.circular_buffer, %class.lock_and_signal } -%class.circular_buffer = type { %class.rust_kernel*, i32, i32, i32, i32, i8* } +%struct.rust_opaque_box = type { i32, %struct.type_desc*, %struct.rust_opaque_box*, %struct.rust_opaque_box* } +%struct.rust_shape_tables = type { i8*, i8* } +%struct.rust_task = type { i32, i32, i8, %struct.chan_handle, [12 x i8], %class.context, %struct.stk_seg*, i32, %class.rust_scheduler*, %struct.rust_task_thread*, %class.rust_crate_cache*, %class.rust_kernel*, i8*, %class.rust_task_list*, %"struct.memory_region::alloc_header"*, i8*, %struct.rust_task*, i32, i32, i32*, %class.memory_region, %class.boxed_region, i8, i8, %class.lock_and_signal, %class.hash_map, %class.rust_obstack, i32, %"class.debug::task_debug_info", i32, i8, i8, %struct.stk_seg*, i32, i32, %class.rust_port_selector, [8 x i8] } +%struct.rust_task_thread = type { %class.rust_thread, i32, %class.rust_log, i32, %class.rust_srv*, i8*, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_crate_cache, %struct.randctx, %class.rust_kernel*, %class.rust_scheduler*, i32, i32, %class.lock_and_signal, i32, %struct._opaque_pthread_attr_t, %struct.rust_env*, [4 x i8], %class.context, i8, %struct.stk_seg*, %struct.stk_seg*, [4 x i8] } +%struct.rust_vec = type { i32, i32, [0 x i8] } +%"struct.std::_Rb_tree<long, std::pair<const long, rust_scheduler *>, std::_Select1st<std::pair<const long, rust_scheduler *> >, std::less<long>, std::allocator<std::pair<const long, rust_scheduler *> > >::_Rb_tree_impl" = type { %"struct.memory_region::alloc_header", %"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.std::_Vector_base" = type { %"struct.std::_Vector_base<long, std::allocator<long> >::_Vector_impl" } +%"struct.std::_Vector_base<long, std::allocator<long> >::_Vector_impl" = type { i32*, i32*, i32* } +%struct.stk_seg = type { %struct.stk_seg*, %struct.stk_seg*, i32, i32, i32, i32, [0 x i8] } +%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, i8*, i8*, %struct.rust_shape_tables*, i32, i32, %struct.UT_hash_handle, i32, [0 x %struct.type_desc*] } define void @rust_intrinsic_vec_len(i32* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %struct.rust_vec** nocapture %vp) nounwind { -entry: - %0 = load %struct.rust_vec** %vp, align 4, !tbaa !0 - %fill = getelementptr inbounds %struct.rust_vec* %0, i32 0, i32 0 - %1 = load i32* %fill, align 4, !tbaa !3 - %size = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1 - %2 = load i32* %size, align 4, !tbaa !3 - %div = udiv i32 %1, %2 - store i32 %div, i32* %retptr, align 4, !tbaa !3 + %1 = load %struct.rust_vec** %vp, align 4 + %2 = getelementptr inbounds %struct.rust_vec* %1, i32 0, i32 0 + %3 = load i32* %2, align 4 + %4 = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1 + %5 = load i32* %4, align 4 + %6 = udiv i32 %3, %5 + store i32 %6, i32* %retptr, align 4 ret void } define void @rust_intrinsic_ptr_offset(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* %ptr, i32 %count) nounwind { -entry: - %size = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1 - %0 = load i32* %size, align 4, !tbaa !3 - %mul = mul i32 %0, %count - %arrayidx = getelementptr inbounds i8* %ptr, i32 %mul - store i8* %arrayidx, i8** %retptr, align 4, !tbaa !0 + %1 = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1 + %2 = load i32* %1, align 4 + %3 = mul i32 %2, %count + %4 = getelementptr inbounds i8* %ptr, i32 %3 + store i8* %4, i8** %retptr, align 4 ret void } define void @rust_intrinsic_cast(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) nounwind { -entry: - %size = getelementptr inbounds %struct.type_desc* %t1, i32 0, i32 1 - %0 = load i32* %size, align 4, !tbaa !3 - tail call void @llvm.memmove.p0i8.p0i8.i32(i8* %retptr, i8* %src, i32 %0, i32 1, i1 false) + %1 = getelementptr inbounds %struct.type_desc* %t1, i32 0, i32 1 + %2 = load i32* %1, align 4 + tail call void @llvm.memmove.p0i8.p0i8.i32(i8* %retptr, i8* %src, i32 %2, i32 1, i1 false) ret void } declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind define void @rust_intrinsic_addr_of(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* %valptr) nounwind { -entry: - store i8* %valptr, i8** %retptr, align 4, !tbaa !0 + store i8* %valptr, i8** %retptr, align 4 ret void } define void @rust_intrinsic_call_with_retptr(i8** %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %struct.rust_fn* nocapture %recvfn) { -entry: - %fn1 = getelementptr inbounds %struct.rust_fn* %recvfn, i32 0, i32 0 - %0 = load i32** %fn1, align 4, !tbaa !0 - %1 = bitcast i32* %0 to void (i8**, i8*, i8**)* - %env2 = getelementptr inbounds %struct.rust_fn* %recvfn, i32 0, i32 1 - %2 = load %struct.rust_box** %env2, align 4, !tbaa !0 - %3 = bitcast %struct.rust_box* %2 to i8* - tail call void %1(i8** null, i8* %3, i8** %retptr) + %1 = getelementptr inbounds %struct.rust_fn* %recvfn, i32 0, i32 0 + %2 = load i32** %1, align 4 + %3 = bitcast i32* %2 to void (i8**, i8*, i8**)* + %4 = getelementptr inbounds %struct.rust_fn* %recvfn, i32 0, i32 1 + %5 = load %struct.rust_box** %4, align 4 + %6 = bitcast %struct.rust_box* %5 to i8* + tail call void %3(i8** null, i8* %6, i8** %retptr) ret void } define void @rust_intrinsic_get_type_desc(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* %ty) nounwind { -entry: %ty.c = bitcast %struct.type_desc* %ty to i8* - store i8* %ty.c, i8** %retptr, align 4, !tbaa !0 + store i8* %ty.c, i8** %retptr, align 4 ret void } define void @rust_intrinsic_task_yield(i8** nocapture %retptr, i8* nocapture %env, %struct.rust_task* %task, i8* %killed) { -entry: tail call void @rust_task_yield(%struct.rust_task* %task, i8* %killed) ret void } @@ -127,114 +116,121 @@ entry: declare void @rust_task_yield(%struct.rust_task*, i8*) define void @rust_intrinsic_memmove(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* nocapture %dst, i8* nocapture %src, i32 %count) nounwind { -entry: - %size = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1 - %0 = load i32* %size, align 4, !tbaa !3 - %mul = mul i32 %0, %count - tail call void @llvm.memmove.p0i8.p0i8.i32(i8* %dst, i8* %src, i32 %mul, i32 1, i1 false) + %1 = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1 + %2 = load i32* %1, align 4 + %3 = mul i32 %2, %count + tail call void @llvm.memmove.p0i8.p0i8.i32(i8* %dst, i8* %src, i32 %3, i32 1, i1 false) ret void } define void @rust_intrinsic_memcpy(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* nocapture %dst, i8* nocapture %src, i32 %count) nounwind { -entry: - %size = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1 - %0 = load i32* %size, align 4, !tbaa !3 - %mul = mul i32 %0, %count - tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dst, i8* %src, i32 %mul, i32 1, i1 false) + %1 = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1 + %2 = load i32* %1, align 4 + %3 = mul i32 %2, %count + tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dst, i8* %src, i32 %3, i32 1, i1 false) ret void } declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind define void @rust_intrinsic_leak(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* nocapture %thing) nounwind readnone { -entry: ret void } define void @upcall_intrinsic_vec_push(%struct.rust_vec** nocapture %vp, %struct.type_desc* nocapture %elt_ty, i8* nocapture %elt) { -entry: - %0 = load %struct.rust_vec** %vp, align 4, !tbaa !0 - %fill = getelementptr inbounds %struct.rust_vec* %0, i32 0, i32 0 - %1 = load i32* %fill, align 4, !tbaa !3 - %size = getelementptr inbounds %struct.type_desc* %elt_ty, i32 0, i32 1 - %2 = load i32* %size, align 4, !tbaa !3 - %add = add i32 %2, %1 - %alloc.i = getelementptr inbounds %struct.rust_vec* %0, i32 0, i32 1 - %3 = load i32* %alloc.i, align 4, !tbaa !3 - %cmp.i = icmp ult i32 %3, %add - br i1 %cmp.i, label %if.then.i, label %_Z16reserve_vec_fastPP8rust_vecj.exit - -if.then.i: ; preds = %entry - %sub.i.i = add i32 %add, -1 - %shr.i.i = lshr i32 %sub.i.i, 1 - %or.i.i = or i32 %shr.i.i, %sub.i.i - %shr1.i.i = lshr i32 %or.i.i, 2 - %or2.i.i = or i32 %shr1.i.i, %or.i.i - %shr3.i.i = lshr i32 %or2.i.i, 4 - %or4.i.i = or i32 %shr3.i.i, %or2.i.i - %shr5.i.i = lshr i32 %or4.i.i, 8 - %or6.i.i = or i32 %shr5.i.i, %or4.i.i - %shr7.i.i = lshr i32 %or6.i.i, 16 - %or8.i.i = or i32 %shr7.i.i, %or6.i.i - %add.i.i = add i32 %or8.i.i, 1 - %add.i = add i32 %or8.i.i, 9 - %4 = bitcast %struct.rust_vec* %0 to i8* - %call1.i = tail call i8* @upcall_shared_realloc(i8* %4, i32 %add.i) - %5 = bitcast i8* %call1.i to %struct.rust_vec* - store %struct.rust_vec* %5, %struct.rust_vec** %vp, align 4, !tbaa !0 - %alloc2.i = getelementptr inbounds i8* %call1.i, i32 4 - %6 = bitcast i8* %alloc2.i to i32* - store i32 %add.i.i, i32* %6, align 4, !tbaa !3 - %.pr = load i32* %size, align 4 - %fill1.phi.trans.insert = bitcast i8* %call1.i to i32* - %.pre = load i32* %fill1.phi.trans.insert, align 4, !tbaa !3 - br label %_Z16reserve_vec_fastPP8rust_vecj.exit - -_Z16reserve_vec_fastPP8rust_vecj.exit: ; preds = %entry, %if.then.i - %7 = phi i32 [ %1, %entry ], [ %.pre, %if.then.i ] - %8 = phi %struct.rust_vec* [ %0, %entry ], [ %5, %if.then.i ] - %9 = phi i32 [ %2, %entry ], [ %.pr, %if.then.i ] - %fill1 = getelementptr inbounds %struct.rust_vec* %8, i32 0, i32 0 - %add.ptr = getelementptr inbounds %struct.rust_vec* %8, i32 0, i32 2, i32 %7 - tail call void @llvm.memmove.p0i8.p0i8.i32(i8* %add.ptr, i8* %elt, i32 %9, i32 1, i1 false) - %take_glue.i = getelementptr inbounds %struct.type_desc* %elt_ty, i32 0, i32 3 - %10 = load void (i8*, i8*, %struct.type_desc**, i8*)** %take_glue.i, align 4, !tbaa !0 - %tobool.i = icmp eq void (i8*, i8*, %struct.type_desc**, i8*)* %10, null - br i1 %tobool.i, label %_ZL13copy_elementsP9type_descPvS1_j.exit, label %if.then.i6 - -if.then.i6: ; preds = %_Z16reserve_vec_fastPP8rust_vecj.exit - %11 = load i32* %size, align 4, !tbaa !3 - %first_param.i = getelementptr inbounds %struct.type_desc* %elt_ty, i32 0, i32 0 - %12 = load %struct.type_desc*** %first_param.i, align 4, !tbaa !0 - %add.ptr.sum = add i32 %7, %9 - %add.ptr.i = getelementptr inbounds %struct.rust_vec* %8, i32 0, i32 2, i32 %add.ptr.sum - %cmp4.i = icmp sgt i32 %9, 0 - br i1 %cmp4.i, label %for.body.i, label %_ZL13copy_elementsP9type_descPvS1_j.exit - -for.body.i: ; preds = %if.then.i6, %for.body.i - %p.05.i = phi i8* [ %add.ptr3.i, %for.body.i ], [ %add.ptr, %if.then.i6 ] - tail call void %10(i8* null, i8* null, %struct.type_desc** %12, i8* %p.05.i) - %add.ptr3.i = getelementptr inbounds i8* %p.05.i, i32 %11 - %cmp.i7 = icmp ult i8* %add.ptr3.i, %add.ptr.i - br i1 %cmp.i7, label %for.body.i, label %_ZL13copy_elementsP9type_descPvS1_j.exit - -_ZL13copy_elementsP9type_descPvS1_j.exit: ; preds = %for.body.i, %_Z16reserve_vec_fastPP8rust_vecj.exit, %if.then.i6 - %13 = load i32* %size, align 4, !tbaa !3 - %14 = load i32* %fill1, align 4, !tbaa !3 - %add5 = add i32 %14, %13 - store i32 %add5, i32* %fill1, align 4, !tbaa !3 +; <label>:0 + %1 = load %struct.rust_vec** %vp, align 4 + %2 = getelementptr inbounds %struct.rust_vec* %1, i32 0, i32 0 + %3 = load i32* %2, align 4 + %4 = getelementptr inbounds %struct.type_desc* %elt_ty, i32 0, i32 1 + %5 = load i32* %4, align 4 + %6 = add i32 %5, %3 + %7 = getelementptr inbounds %struct.rust_vec* %1, i32 0, i32 1 + %8 = load i32* %7, align 4 + %9 = icmp ult i32 %8, %6 + br i1 %9, label %10, label %_Z16reserve_vec_fastPP8rust_vecm.exit + +; <label>:10 ; preds = %0 + %11 = add i32 %6, -1 + %12 = lshr i32 %11, 1 + %13 = or i32 %12, %11 + %14 = lshr i32 %13, 2 + %15 = or i32 %14, %13 + %16 = lshr i32 %15, 4 + %17 = or i32 %16, %15 + %18 = lshr i32 %17, 8 + %19 = or i32 %18, %17 + %20 = lshr i32 %19, 16 + %21 = or i32 %20, %19 + %22 = add i32 %21, 1 + %23 = add i32 %21, 9 + %24 = bitcast %struct.rust_vec* %1 to i8* + %25 = tail call i8* @upcall_shared_realloc(i8* %24, i32 %23) + %26 = bitcast i8* %25 to %struct.rust_vec* + store %struct.rust_vec* %26, %struct.rust_vec** %vp, align 4 + %27 = getelementptr inbounds i8* %25, i32 4 + %28 = bitcast i8* %27 to i32* + store i32 %22, i32* %28, align 4 + %.pr = load i32* %4, align 4 + %.pre = load %struct.rust_vec** %vp, align 4 + %.phi.trans.insert = getelementptr inbounds %struct.rust_vec* %.pre, i32 0, i32 0 + %.pre4 = load i32* %.phi.trans.insert, align 4 + br label %_Z16reserve_vec_fastPP8rust_vecm.exit + +_Z16reserve_vec_fastPP8rust_vecm.exit: ; preds = %0, %10 + %29 = phi i32 [ %3, %0 ], [ %.pre4, %10 ] + %30 = phi %struct.rust_vec* [ %1, %0 ], [ %.pre, %10 ] + %31 = phi i32 [ %5, %0 ], [ %.pr, %10 ] + %32 = getelementptr inbounds %struct.rust_vec* %30, i32 0, i32 0 + %33 = getelementptr inbounds %struct.rust_vec* %30, i32 0, i32 2, i32 %29 + tail call void @llvm.memmove.p0i8.p0i8.i32(i8* %33, i8* %elt, i32 %31, i32 1, i1 false) + %34 = getelementptr inbounds %struct.type_desc* %elt_ty, i32 0, i32 3 + %35 = load void (i8*, i8*, %struct.type_desc**, i8*)** %34, align 4 + %36 = icmp eq void (i8*, i8*, %struct.type_desc**, i8*)* %35, null + br i1 %36, label %_ZL13copy_elementsP9type_descPvS1_m.exit, label %37 + +; <label>:37 ; preds = %_Z16reserve_vec_fastPP8rust_vecm.exit + %38 = load i32* %4, align 4 + %39 = getelementptr inbounds %struct.type_desc* %elt_ty, i32 0, i32 0 + %40 = load %struct.type_desc*** %39, align 4 + %41 = icmp sgt i32 %31, 0 + br i1 %41, label %.lr.ph.i.preheader, label %_ZL13copy_elementsP9type_descPvS1_m.exit + +.lr.ph.i.preheader: ; preds = %37 + %scevgep = getelementptr %struct.rust_vec* %30, i32 1, i32 0 + %scevgep2 = bitcast i32* %scevgep to i8* + br label %.lr.ph.i + +.lr.ph.i: ; preds = %.lr.ph.i.preheader, %.lr.ph.i + %indvar.i = phi i32 [ %indvar.next.i, %.lr.ph.i ], [ 0, %.lr.ph.i.preheader ] + %tmp = mul i32 %38, %indvar.i + %tmp2.i = add i32 %38, %tmp + %tmp3 = add i32 %29, %tmp + %p.01.i = getelementptr i8* %scevgep2, i32 %tmp3 + tail call void %35(i8* null, i8* null, %struct.type_desc** %40, i8* %p.01.i) + %42 = icmp slt i32 %tmp2.i, %31 + %indvar.next.i = add i32 %indvar.i, 1 + br i1 %42, label %.lr.ph.i, label %_ZL13copy_elementsP9type_descPvS1_m.exit + +_ZL13copy_elementsP9type_descPvS1_m.exit: ; preds = %.lr.ph.i, %_Z16reserve_vec_fastPP8rust_vecm.exit, %37 + %43 = load i32* %4, align 4 + %44 = load i32* %32, align 4 + %45 = add i32 %44, %43 + store i32 %45, i32* %32, align 4 ret void } define void @upcall_vec_push(%struct.rust_vec** nocapture %vp, %struct.type_desc* nocapture %elt_ty, i8* nocapture %elt) { -entry: tail call void @upcall_intrinsic_vec_push(%struct.rust_vec** %vp, %struct.type_desc* %elt_ty, i8* %elt) ret void } -declare i8* @upcall_shared_realloc(i8*, i32) +define void @rust_intrinsic_frame_address(i8** nocapture %p) nounwind { + %1 = tail call i8* @llvm.frameaddress(i32 1) + store i8* %1, i8** %p, align 4 + ret void +} + +declare i8* @llvm.frameaddress(i32) nounwind readnone -!0 = metadata !{metadata !"any pointer", metadata !1} -!1 = metadata !{metadata !"omnipotent char", metadata !2} -!2 = metadata !{metadata !"Simple C/C++ TBAA", null} -!3 = metadata !{metadata !"int", metadata !1} +declare i8* @upcall_shared_realloc(i8*, i32) diff --git a/src/rt/intrinsics/intrinsics.x86_64.ll.in b/src/rt/intrinsics/intrinsics.x86_64.ll.in index 7a5045050d4..d18c1f7c9e4 100644 --- a/src/rt/intrinsics/intrinsics.x86_64.ll.in +++ b/src/rt/intrinsics/intrinsics.x86_64.ll.in @@ -1,242 +1,237 @@ ; ModuleID = 'src/rt/intrinsics/intrinsics.cpp' -; target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +; target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "@CFG_TARGET_TRIPLE@" -%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, i8*, i8*, %struct.rust_shape_tables*, i64, i64, %struct.UT_hash_handle, i64, [0 x %struct.type_desc*] } -%struct.rust_shape_tables = type { i8*, i8* } -%struct.UT_hash_handle = type { %struct.UT_hash_table*, i8*, i8*, %struct.UT_hash_handle*, %struct.UT_hash_handle*, i8*, i32, i32 } -%struct.UT_hash_table = type { %struct.UT_hash_bucket*, i32, i32, i32, %struct.UT_hash_handle*, i64, i32, i32, i32, i32 } -%struct.UT_hash_bucket = type { %struct.UT_hash_handle*, i32, i32 } -%struct.rust_vec = type { i64, i64, [0 x i8] } -%struct.rust_fn = type { i64*, %struct.rust_box* } -%struct.rust_box = type opaque -%struct.rust_task = type { i64, i64, i8, %struct.chan_handle, [8 x i8], %class.context, %struct.stk_seg*, i64, %class.rust_scheduler*, %struct.rust_task_thread*, %class.rust_crate_cache*, %class.rust_kernel*, i8*, %class.rust_task_list*, %struct.rust_cond*, i8*, %struct.rust_task*, i32, i64, i64*, %class.memory_region, %class.boxed_region, i8, i8, %class.lock_and_signal, %class.hash_map.3, %class.rust_obstack, i32, %"class.debug::task_debug_info", i64, i8, i8, %struct.stk_seg*, i64, i64, %class.rust_port_selector, [8 x i8] } -%struct.chan_handle = type { i64, i64 } +%0 = type { i64, %struct.rust_task**, i64 } +%1 = type { %"struct.hash_map<long, rust_task *>::map_entry"* } +%class.array_list = type { i64, %"struct.memory_region::alloc_header"**, i64 } +%class.boxed_region = type { %class.memory_region*, %struct.rust_opaque_box* } +%class.circular_buffer = type { %class.rust_kernel*, i64, i64, i64, i64, i8* } %class.context = type { %struct.registers_t, %class.context*, [8 x i8] } -%struct.registers_t = type { [22 x i64] } -%struct.stk_seg = type { %struct.stk_seg*, %struct.stk_seg*, i64, i32, i64, [0 x i8] } -%class.rust_scheduler = type opaque -%struct.rust_task_thread = type { %class.rust_thread, i64, %class.rust_log, i32, %class.rust_srv*, i8*, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_crate_cache, %struct.randctx, %class.rust_kernel*, %class.rust_scheduler*, i32, i32, %class.lock_and_signal, i64, %union.pthread_attr_t, %struct.rust_env*, %class.context, i8, %struct.stk_seg*, %struct.stk_seg*, [8 x i8] } -%class.rust_thread = type { i32 (...)**, i64, i64 } +%"class.debug::task_debug_info" = type { %"class.std::map" } +%class.hash_map = type { %"struct.hash_map<long, rust_port *>::map_entry"* } +%class.indexed_list = type { i32 (...)**, %0 } +%class.lock_and_signal = type { i32 (...)**, %struct._opaque_pthread_cond_t, %struct._opaque_pthread_attr_t, %struct._opaque_pthread_t* } +%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %class.array_list, i8, i8, %class.lock_and_signal } +%class.rust_crate_cache = type { %struct.type_desc*, %struct.rust_hashable_dict*, %struct.rust_task_thread*, i64 } +%class.rust_kernel = type { %class.memory_region, %class.rust_log, %class.rust_srv*, %class.lock_and_signal, i64, i64, %1, %class.lock_and_signal, i32, %class.lock_and_signal, i64, %"class.std::map", %"class.std::vector", %struct.rust_env* } %class.rust_log = type { i32 (...)**, %class.rust_srv*, %struct.rust_task_thread*, i8 } +%class.rust_obstack = type { %struct.rust_obstack_chunk*, %struct.rust_task* } +%class.rust_port = type { i64, i64, %class.rust_kernel*, %struct.rust_task*, i64, %class.circular_buffer, %class.lock_and_signal } +%class.rust_port_selector = type { %class.rust_port**, i64, %class.lock_and_signal } +%class.rust_scheduler = type opaque %class.rust_srv = type { i32 (...)**, %struct.rust_env*, %class.memory_region } -%struct.rust_env = type { i64, i64, i64, i8*, i8, i8, i8* } -%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %class.array_list, i8, i8, %class.lock_and_signal } -%class.array_list = type { i64, %"struct.memory_region::alloc_header"**, i64 } -%"struct.memory_region::alloc_header" = type { i8 } -%class.lock_and_signal = type { i32 (...)**, %union.pthread_cond_t, %union.pthread_mutex_t, i64 } -%union.pthread_cond_t = type { %struct.anon } -%struct.anon = type { i32, i32, i64, i64, i64, i8*, i32, i32 } -%union.pthread_mutex_t = type { %"struct.<anonymous union>::__pthread_mutex_s" } -%"struct.<anonymous union>::__pthread_mutex_s" = type { i32, i32, i32, i32, i32, i32, %struct.__pthread_internal_list } -%struct.__pthread_internal_list = type { %struct.__pthread_internal_list*, %struct.__pthread_internal_list* } %class.rust_task_list = type { %class.indexed_list, %struct.rust_task_thread*, i8* } -%class.indexed_list = type { i32 (...)**, %class.array_list.1 } -%class.array_list.1 = type { i64, %struct.rust_task**, i64 } -%class.rust_crate_cache = type { %struct.type_desc*, %struct.rust_hashable_dict*, %struct.rust_task_thread*, i64 } -%struct.rust_hashable_dict = type { %struct.UT_hash_handle, [0 x i8*] } -%struct.randctx = type { i64, [256 x i64], [256 x i64], i64, i64, i64 } -%class.rust_kernel = type { %class.memory_region, %class.rust_log, %class.rust_srv*, %class.lock_and_signal, i64, i64, %class.hash_map, %class.lock_and_signal, i32, %class.lock_and_signal, i64, i64, %"class.std::map", %struct.rust_env* } -%class.hash_map = type { %"struct.hash_map<long, rust_task *>::map_entry"* } -%"struct.hash_map<long, rust_task *>::map_entry" = type opaque -%"class.std::map" = type { %"class.std::_Rb_tree" } +%class.rust_thread = type { i32 (...)**, %struct._opaque_pthread_t*, i64 } %"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<long, std::pair<const long, rust_scheduler *>, std::_Select1st<std::pair<const long, rust_scheduler *> >, std::less<long>, std::allocator<std::pair<const long, rust_scheduler *> > >::_Rb_tree_impl" } -%"struct.std::_Rb_tree<long, std::pair<const long, rust_scheduler *>, std::_Select1st<std::pair<const long, rust_scheduler *> >, std::less<long>, std::allocator<std::pair<const long, rust_scheduler *> > >::_Rb_tree_impl" = type { %"struct.std::less", %"struct.std::_Rb_tree_node_base", i64 } -%"struct.std::less" = type { i8 } -%"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"* } -%union.pthread_attr_t = type { i64, [48 x i8] } -%struct.rust_cond = type { i8 } -%class.boxed_region = type { %class.memory_region*, %struct.rust_opaque_box* } -%struct.rust_opaque_box = type { i64, %struct.type_desc*, %struct.rust_opaque_box*, %struct.rust_opaque_box* } -%class.hash_map.3 = type { %"struct.hash_map<long, rust_port *>::map_entry"* } +%"class.std::map" = type { %"class.std::_Rb_tree" } +%"class.std::vector" = type { %"struct.std::_Vector_base" } +%struct.UT_hash_bucket = type { %struct.UT_hash_handle*, i32, i32 } +%struct.UT_hash_handle = type { %struct.UT_hash_table*, i8*, i8*, %struct.UT_hash_handle*, %struct.UT_hash_handle*, i8*, i32, i32 } +%struct.UT_hash_table = type { %struct.UT_hash_bucket*, i32, i32, i32, %struct.UT_hash_handle*, i64, i32, i32, i32, i32 } +%struct.__darwin_pthread_handler_rec = type { void (i8*)*, i8*, %struct.__darwin_pthread_handler_rec* } +%struct._opaque_pthread_attr_t = type { i64, [56 x i8] } +%struct._opaque_pthread_cond_t = type { i64, [40 x i8] } +%struct._opaque_pthread_t = type { i64, %struct.__darwin_pthread_handler_rec*, [1168 x i8] } +%struct.chan_handle = type { i64, i64 } %"struct.hash_map<long, rust_port *>::map_entry" = type opaque -%class.rust_obstack = type { %struct.rust_obstack_chunk*, %struct.rust_task* } +%"struct.hash_map<long, rust_task *>::map_entry" = type opaque +%"struct.memory_region::alloc_header" = type { i8 } +%struct.randctx = type { i64, [256 x i64], [256 x i64], i64, i64, i64 } +%struct.registers_t = type { [22 x i64] } +%struct.rust_box = type opaque +%struct.rust_env = type { i64, i64, i64, i8*, i8, i8, i8* } +%struct.rust_fn = type { i64*, %struct.rust_box* } +%struct.rust_hashable_dict = type { %struct.UT_hash_handle, [0 x i8*] } %struct.rust_obstack_chunk = type { %struct.rust_obstack_chunk*, i64, i64, i64, [0 x i8] } -%"class.debug::task_debug_info" = type { %"class.std::map.4" } -%"class.std::map.4" = type { %"class.std::_Rb_tree.5" } -%"class.std::_Rb_tree.5" = type { %"struct.std::_Rb_tree<void *, std::pair<void *const, std::basic_string<char> >, std::_Select1st<std::pair<void *const, std::basic_string<char> > >, std::less<void *>, std::allocator<std::pair<void *const, std::basic_string<char> > > >::_Rb_tree_impl" } -%"struct.std::_Rb_tree<void *, std::pair<void *const, std::basic_string<char> >, std::_Select1st<std::pair<void *const, std::basic_string<char> > >, std::less<void *>, std::allocator<std::pair<void *const, std::basic_string<char> > > >::_Rb_tree_impl" = type { %"struct.std::less.9", %"struct.std::_Rb_tree_node_base", i64 } -%"struct.std::less.9" = type { i8 } -%class.rust_port_selector = type { %class.rust_port**, i64, %class.lock_and_signal } -%class.rust_port = type { i64, i64, %class.rust_kernel*, %struct.rust_task*, i64, %class.circular_buffer, %class.lock_and_signal } -%class.circular_buffer = type { %class.rust_kernel*, i64, i64, i64, i64, i8* } +%struct.rust_opaque_box = type { i64, %struct.type_desc*, %struct.rust_opaque_box*, %struct.rust_opaque_box* } +%struct.rust_shape_tables = type { i8*, i8* } +%struct.rust_task = type { i64, i64, i8, %struct.chan_handle, [8 x i8], %class.context, %struct.stk_seg*, i64, %class.rust_scheduler*, %struct.rust_task_thread*, %class.rust_crate_cache*, %class.rust_kernel*, i8*, %class.rust_task_list*, %"struct.memory_region::alloc_header"*, i8*, %struct.rust_task*, i32, i64, i64*, %class.memory_region, %class.boxed_region, i8, i8, %class.lock_and_signal, %class.hash_map, %class.rust_obstack, i32, %"class.debug::task_debug_info", i64, i8, i8, %struct.stk_seg*, i64, i64, %class.rust_port_selector } +%struct.rust_task_thread = type { %class.rust_thread, i64, %class.rust_log, i32, %class.rust_srv*, i8*, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_crate_cache, %struct.randctx, %class.rust_kernel*, %class.rust_scheduler*, i32, i32, %class.lock_and_signal, i64, %struct._opaque_pthread_attr_t, %struct.rust_env*, %class.context, i8, %struct.stk_seg*, %struct.stk_seg*, [8 x i8] } +%struct.rust_vec = type { i64, i64, [0 x i8] } +%"struct.std::_Rb_tree<long, std::pair<const long, rust_scheduler *>, std::_Select1st<std::pair<const long, rust_scheduler *> >, std::less<long>, std::allocator<std::pair<const long, rust_scheduler *> > >::_Rb_tree_impl" = type { %"struct.memory_region::alloc_header", %"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.std::_Vector_base" = type { %"struct.std::_Vector_base<long, std::allocator<long> >::_Vector_impl" } +%"struct.std::_Vector_base<long, std::allocator<long> >::_Vector_impl" = type { i64*, i64*, i64* } +%struct.stk_seg = type { %struct.stk_seg*, %struct.stk_seg*, i64, i32, i64, [0 x i8] } +%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, i8*, i8*, %struct.rust_shape_tables*, i64, i64, %struct.UT_hash_handle, i64, [0 x %struct.type_desc*] } -define void @rust_intrinsic_vec_len(i64* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %struct.rust_vec** nocapture %vp) nounwind uwtable { -entry: - %0 = load %struct.rust_vec** %vp, align 8, !tbaa !0 - %fill = getelementptr inbounds %struct.rust_vec* %0, i64 0, i32 0 - %1 = load i64* %fill, align 8, !tbaa !3 - %size = getelementptr inbounds %struct.type_desc* %ty, i64 0, i32 1 - %2 = load i64* %size, align 8, !tbaa !3 - %div = udiv i64 %1, %2 - store i64 %div, i64* %retptr, align 8, !tbaa !3 +define void @rust_intrinsic_vec_len(i64* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %struct.rust_vec** nocapture %vp) nounwind { + %1 = load %struct.rust_vec** %vp, align 8 + %2 = getelementptr inbounds %struct.rust_vec* %1, i64 0, i32 0 + %3 = load i64* %2, align 8 + %4 = getelementptr inbounds %struct.type_desc* %ty, i64 0, i32 1 + %5 = load i64* %4, align 8 + %6 = udiv i64 %3, %5 + store i64 %6, i64* %retptr, align 8 ret void } -define void @rust_intrinsic_ptr_offset(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* %ptr, i64 %count) nounwind uwtable { -entry: - %size = getelementptr inbounds %struct.type_desc* %ty, i64 0, i32 1 - %0 = load i64* %size, align 8, !tbaa !3 - %mul = mul i64 %0, %count - %arrayidx = getelementptr inbounds i8* %ptr, i64 %mul - store i8* %arrayidx, i8** %retptr, align 8, !tbaa !0 +define void @rust_intrinsic_ptr_offset(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* %ptr, i64 %count) nounwind { + %1 = getelementptr inbounds %struct.type_desc* %ty, i64 0, i32 1 + %2 = load i64* %1, align 8 + %3 = mul i64 %2, %count + %4 = getelementptr inbounds i8* %ptr, i64 %3 + store i8* %4, i8** %retptr, align 8 ret void } -define void @rust_intrinsic_cast(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) nounwind uwtable { -entry: - %size = getelementptr inbounds %struct.type_desc* %t1, i64 0, i32 1 - %0 = load i64* %size, align 8, !tbaa !3 - tail call void @llvm.memmove.p0i8.p0i8.i64(i8* %retptr, i8* %src, i64 %0, i32 1, i1 false) +define void @rust_intrinsic_cast(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) nounwind { + %1 = getelementptr inbounds %struct.type_desc* %t1, i64 0, i32 1 + %2 = load i64* %1, align 8 + tail call void @llvm.memmove.p0i8.p0i8.i64(i8* %retptr, i8* %src, i64 %2, i32 1, i1 false) ret void } declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind -define void @rust_intrinsic_addr_of(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* %valptr) nounwind uwtable { -entry: - store i8* %valptr, i8** %retptr, align 8, !tbaa !0 +define void @rust_intrinsic_addr_of(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* %valptr) nounwind { + store i8* %valptr, i8** %retptr, align 8 ret void } -define void @rust_intrinsic_call_with_retptr(i8** %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %struct.rust_fn* nocapture %recvfn) uwtable { -entry: - %fn1 = getelementptr inbounds %struct.rust_fn* %recvfn, i64 0, i32 0 - %0 = load i64** %fn1, align 8, !tbaa !0 - %1 = bitcast i64* %0 to void (i8**, i8*, i8**)* - %env2 = getelementptr inbounds %struct.rust_fn* %recvfn, i64 0, i32 1 - %2 = load %struct.rust_box** %env2, align 8, !tbaa !0 - %3 = bitcast %struct.rust_box* %2 to i8* - tail call void %1(i8** null, i8* %3, i8** %retptr) +define void @rust_intrinsic_call_with_retptr(i8** %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %struct.rust_fn* nocapture %recvfn) { + %1 = getelementptr inbounds %struct.rust_fn* %recvfn, i64 0, i32 0 + %2 = load i64** %1, align 8 + %3 = bitcast i64* %2 to void (i8**, i8*, i8**)* + %4 = getelementptr inbounds %struct.rust_fn* %recvfn, i64 0, i32 1 + %5 = load %struct.rust_box** %4, align 8 + %6 = bitcast %struct.rust_box* %5 to i8* + tail call void %3(i8** null, i8* %6, i8** %retptr) ret void } -define void @rust_intrinsic_get_type_desc(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* %ty) nounwind uwtable { -entry: +define void @rust_intrinsic_get_type_desc(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* %ty) nounwind { %ty.c = bitcast %struct.type_desc* %ty to i8* - store i8* %ty.c, i8** %retptr, align 8, !tbaa !0 + store i8* %ty.c, i8** %retptr, align 8 ret void } -define void @rust_intrinsic_task_yield(i8** nocapture %retptr, i8* nocapture %env, %struct.rust_task* %task, i8* %killed) uwtable { -entry: +define void @rust_intrinsic_task_yield(i8** nocapture %retptr, i8* nocapture %env, %struct.rust_task* %task, i8* %killed) { tail call void @rust_task_yield(%struct.rust_task* %task, i8* %killed) ret void } declare void @rust_task_yield(%struct.rust_task*, i8*) -define void @rust_intrinsic_memmove(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* nocapture %dst, i8* nocapture %src, i64 %count) nounwind uwtable { -entry: - %size = getelementptr inbounds %struct.type_desc* %ty, i64 0, i32 1 - %0 = load i64* %size, align 8, !tbaa !3 - %mul = mul i64 %0, %count - tail call void @llvm.memmove.p0i8.p0i8.i64(i8* %dst, i8* %src, i64 %mul, i32 1, i1 false) +define void @rust_intrinsic_memmove(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* nocapture %dst, i8* nocapture %src, i64 %count) nounwind { + %1 = getelementptr inbounds %struct.type_desc* %ty, i64 0, i32 1 + %2 = load i64* %1, align 8 + %3 = mul i64 %2, %count + tail call void @llvm.memmove.p0i8.p0i8.i64(i8* %dst, i8* %src, i64 %3, i32 1, i1 false) ret void } -define void @rust_intrinsic_memcpy(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* nocapture %dst, i8* nocapture %src, i64 %count) nounwind uwtable { -entry: - %size = getelementptr inbounds %struct.type_desc* %ty, i64 0, i32 1 - %0 = load i64* %size, align 8, !tbaa !3 - %mul = mul i64 %0, %count - tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %src, i64 %mul, i32 1, i1 false) +define void @rust_intrinsic_memcpy(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* nocapture %dst, i8* nocapture %src, i64 %count) nounwind { + %1 = getelementptr inbounds %struct.type_desc* %ty, i64 0, i32 1 + %2 = load i64* %1, align 8 + %3 = mul i64 %2, %count + tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %src, i64 %3, i32 1, i1 false) ret void } declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind -define void @rust_intrinsic_leak(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* nocapture %thing) nounwind uwtable readnone { -entry: +define void @rust_intrinsic_leak(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* nocapture %thing) nounwind readnone { ret void } -define void @upcall_intrinsic_vec_push(%struct.rust_vec** nocapture %vp, %struct.type_desc* nocapture %elt_ty, i8* nocapture %elt) uwtable { -entry: - %0 = load %struct.rust_vec** %vp, align 8, !tbaa !0 - %fill = getelementptr inbounds %struct.rust_vec* %0, i64 0, i32 0 - %1 = load i64* %fill, align 8, !tbaa !3 - %size = getelementptr inbounds %struct.type_desc* %elt_ty, i64 0, i32 1 - %2 = load i64* %size, align 8, !tbaa !3 - %add = add i64 %2, %1 - %alloc.i = getelementptr inbounds %struct.rust_vec* %0, i64 0, i32 1 - %3 = load i64* %alloc.i, align 8, !tbaa !3 - %cmp.i = icmp ult i64 %3, %add - br i1 %cmp.i, label %if.then.i, label %_Z16reserve_vec_fastPP8rust_vecm.exit - -if.then.i: ; preds = %entry - %sub.i.i = add i64 %add, -1 - %shr.i.i = lshr i64 %sub.i.i, 1 - %or.i.i = or i64 %shr.i.i, %sub.i.i - %shr1.i.i = lshr i64 %or.i.i, 2 - %or2.i.i = or i64 %shr1.i.i, %or.i.i - %shr3.i.i = lshr i64 %or2.i.i, 4 - %or4.i.i = or i64 %shr3.i.i, %or2.i.i - %shr5.i.i = lshr i64 %or4.i.i, 8 - %or6.i.i = or i64 %shr5.i.i, %or4.i.i - %shr7.i.i = lshr i64 %or6.i.i, 16 - %or8.i.i = or i64 %shr7.i.i, %or6.i.i - %shr9.i.i = lshr i64 %or8.i.i, 32 - %or10.i.i = or i64 %shr9.i.i, %or8.i.i - %add.i.i = add i64 %or10.i.i, 1 - %add.i = add i64 %or10.i.i, 17 - %4 = bitcast %struct.rust_vec* %0 to i8* - %call1.i = tail call i8* @upcall_shared_realloc(i8* %4, i64 %add.i) - %5 = bitcast i8* %call1.i to %struct.rust_vec* - store %struct.rust_vec* %5, %struct.rust_vec** %vp, align 8, !tbaa !0 - %alloc2.i = getelementptr inbounds i8* %call1.i, i64 8 - %6 = bitcast i8* %alloc2.i to i64* - store i64 %add.i.i, i64* %6, align 8, !tbaa !3 - %.pr = load i64* %size, align 8 - %fill1.phi.trans.insert = bitcast i8* %call1.i to i64* - %.pre = load i64* %fill1.phi.trans.insert, align 8, !tbaa !3 +define void @upcall_intrinsic_vec_push(%struct.rust_vec** nocapture %vp, %struct.type_desc* nocapture %elt_ty, i8* nocapture %elt) { +; <label>:0 + %1 = load %struct.rust_vec** %vp, align 8 + %2 = getelementptr inbounds %struct.rust_vec* %1, i64 0, i32 0 + %3 = load i64* %2, align 8 + %4 = getelementptr inbounds %struct.type_desc* %elt_ty, i64 0, i32 1 + %5 = load i64* %4, align 8 + %6 = add i64 %5, %3 + %7 = getelementptr inbounds %struct.rust_vec* %1, i64 0, i32 1 + %8 = load i64* %7, align 8 + %9 = icmp ult i64 %8, %6 + br i1 %9, label %10, label %_Z16reserve_vec_fastPP8rust_vecm.exit + +; <label>:10 ; preds = %0 + %11 = add i64 %6, -1 + %12 = lshr i64 %11, 1 + %13 = or i64 %12, %11 + %14 = lshr i64 %13, 2 + %15 = or i64 %14, %13 + %16 = lshr i64 %15, 4 + %17 = or i64 %16, %15 + %18 = lshr i64 %17, 8 + %19 = or i64 %18, %17 + %20 = lshr i64 %19, 16 + %21 = or i64 %20, %19 + %22 = lshr i64 %21, 32 + %23 = or i64 %22, %21 + %24 = add i64 %23, 1 + %25 = add i64 %23, 17 + %26 = bitcast %struct.rust_vec* %1 to i8* + %27 = tail call i8* @upcall_shared_realloc(i8* %26, i64 %25) + %28 = bitcast i8* %27 to %struct.rust_vec* + store %struct.rust_vec* %28, %struct.rust_vec** %vp, align 8 + %29 = getelementptr inbounds i8* %27, i64 8 + %30 = bitcast i8* %29 to i64* + store i64 %24, i64* %30, align 8 + %.pr = load i64* %4, align 8 + %.pre = load %struct.rust_vec** %vp, align 8 + %.phi.trans.insert = getelementptr inbounds %struct.rust_vec* %.pre, i64 0, i32 0 + %.pre4 = load i64* %.phi.trans.insert, align 8 br label %_Z16reserve_vec_fastPP8rust_vecm.exit -_Z16reserve_vec_fastPP8rust_vecm.exit: ; preds = %entry, %if.then.i - %7 = phi i64 [ %1, %entry ], [ %.pre, %if.then.i ] - %8 = phi %struct.rust_vec* [ %0, %entry ], [ %5, %if.then.i ] - %9 = phi i64 [ %2, %entry ], [ %.pr, %if.then.i ] - %fill1 = getelementptr inbounds %struct.rust_vec* %8, i64 0, i32 0 - %add.ptr = getelementptr inbounds %struct.rust_vec* %8, i64 0, i32 2, i64 %7 - tail call void @llvm.memmove.p0i8.p0i8.i64(i8* %add.ptr, i8* %elt, i64 %9, i32 1, i1 false) - %take_glue.i = getelementptr inbounds %struct.type_desc* %elt_ty, i64 0, i32 3 - %10 = load void (i8*, i8*, %struct.type_desc**, i8*)** %take_glue.i, align 8, !tbaa !0 - %tobool.i = icmp eq void (i8*, i8*, %struct.type_desc**, i8*)* %10, null - br i1 %tobool.i, label %_ZL13copy_elementsP9type_descPvS1_m.exit, label %if.then.i6 - -if.then.i6: ; preds = %_Z16reserve_vec_fastPP8rust_vecm.exit - %11 = load i64* %size, align 8, !tbaa !3 - %first_param.i = getelementptr inbounds %struct.type_desc* %elt_ty, i64 0, i32 0 - %12 = load %struct.type_desc*** %first_param.i, align 8, !tbaa !0 - %add.ptr.sum = add i64 %7, %9 - %add.ptr.i = getelementptr inbounds %struct.rust_vec* %8, i64 0, i32 2, i64 %add.ptr.sum - %cmp4.i = icmp sgt i64 %9, 0 - br i1 %cmp4.i, label %for.body.i, label %_ZL13copy_elementsP9type_descPvS1_m.exit - -for.body.i: ; preds = %if.then.i6, %for.body.i - %p.05.i = phi i8* [ %add.ptr3.i, %for.body.i ], [ %add.ptr, %if.then.i6 ] - tail call void %10(i8* null, i8* null, %struct.type_desc** %12, i8* %p.05.i) - %add.ptr3.i = getelementptr inbounds i8* %p.05.i, i64 %11 - %cmp.i7 = icmp ult i8* %add.ptr3.i, %add.ptr.i - br i1 %cmp.i7, label %for.body.i, label %_ZL13copy_elementsP9type_descPvS1_m.exit - -_ZL13copy_elementsP9type_descPvS1_m.exit: ; preds = %for.body.i, %_Z16reserve_vec_fastPP8rust_vecm.exit, %if.then.i6 - %13 = load i64* %size, align 8, !tbaa !3 - %14 = load i64* %fill1, align 8, !tbaa !3 - %add5 = add i64 %14, %13 - store i64 %add5, i64* %fill1, align 8, !tbaa !3 +_Z16reserve_vec_fastPP8rust_vecm.exit: ; preds = %0, %10 + %31 = phi i64 [ %3, %0 ], [ %.pre4, %10 ] + %32 = phi %struct.rust_vec* [ %1, %0 ], [ %.pre, %10 ] + %33 = phi i64 [ %5, %0 ], [ %.pr, %10 ] + %34 = getelementptr inbounds %struct.rust_vec* %32, i64 0, i32 0 + %35 = getelementptr inbounds %struct.rust_vec* %32, i64 0, i32 2, i64 %31 + tail call void @llvm.memmove.p0i8.p0i8.i64(i8* %35, i8* %elt, i64 %33, i32 1, i1 false) + %36 = getelementptr inbounds %struct.type_desc* %elt_ty, i64 0, i32 3 + %37 = load void (i8*, i8*, %struct.type_desc**, i8*)** %36, align 8 + %38 = icmp eq void (i8*, i8*, %struct.type_desc**, i8*)* %37, null + br i1 %38, label %_ZL13copy_elementsP9type_descPvS1_m.exit, label %39 + +; <label>:39 ; preds = %_Z16reserve_vec_fastPP8rust_vecm.exit + %40 = load i64* %4, align 8 + %41 = getelementptr inbounds %struct.type_desc* %elt_ty, i64 0, i32 0 + %42 = load %struct.type_desc*** %41, align 8 + %43 = icmp sgt i64 %33, 0 + br i1 %43, label %.lr.ph.i.preheader, label %_ZL13copy_elementsP9type_descPvS1_m.exit + +.lr.ph.i.preheader: ; preds = %39 + %scevgep = getelementptr %struct.rust_vec* %32, i64 1, i32 0 + %scevgep2 = bitcast i64* %scevgep to i8* + br label %.lr.ph.i + +.lr.ph.i: ; preds = %.lr.ph.i.preheader, %.lr.ph.i + %indvar.i = phi i64 [ %indvar.next.i, %.lr.ph.i ], [ 0, %.lr.ph.i.preheader ] + %tmp = mul i64 %40, %indvar.i + %tmp2.i = add i64 %40, %tmp + %tmp3 = add i64 %31, %tmp + %p.01.i = getelementptr i8* %scevgep2, i64 %tmp3 + tail call void %37(i8* null, i8* null, %struct.type_desc** %42, i8* %p.01.i) + %44 = icmp slt i64 %tmp2.i, %33 + %indvar.next.i = add i64 %indvar.i, 1 + br i1 %44, label %.lr.ph.i, label %_ZL13copy_elementsP9type_descPvS1_m.exit + +_ZL13copy_elementsP9type_descPvS1_m.exit: ; preds = %.lr.ph.i, %_Z16reserve_vec_fastPP8rust_vecm.exit, %39 + %45 = load i64* %4, align 8 + %46 = load i64* %34, align 8 + %47 = add i64 %46, %45 + store i64 %47, i64* %34, align 8 ret void } -define void @upcall_vec_push(%struct.rust_vec** nocapture %vp, %struct.type_desc* nocapture %elt_ty, i8* nocapture %elt) uwtable { -entry: +define void @upcall_vec_push(%struct.rust_vec** nocapture %vp, %struct.type_desc* nocapture %elt_ty, i8* nocapture %elt) { tail call void @upcall_intrinsic_vec_push(%struct.rust_vec** %vp, %struct.type_desc* %elt_ty, i8* %elt) ret void } -declare i8* @upcall_shared_realloc(i8*, i64) +define void @rust_intrinsic_frame_address(i8** nocapture %p) nounwind { + %1 = tail call i8* @llvm.frameaddress(i32 1) + store i8* %1, i8** %p, align 8 + ret void +} + +declare i8* @llvm.frameaddress(i32) nounwind readnone -!0 = metadata !{metadata !"any pointer", metadata !1} -!1 = metadata !{metadata !"omnipotent char", metadata !2} -!2 = metadata !{metadata !"Simple C/C++ TBAA", null} -!3 = metadata !{metadata !"long", metadata !1} +declare i8* @upcall_shared_realloc(i8*, i64) diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index a1b2d9eb45a..cacae7259ca 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -682,11 +682,6 @@ rust_dbg_call(dbg_callback cb, void *data) { return cb(data); } -extern "C" CDECL void * -rust_frame_address() { - return __builtin_frame_address(1); -} - // // Local Variables: // mode: C++ diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index 3ccee2ea508..79255a63dd8 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -101,4 +101,3 @@ rust_dbg_lock_unlock rust_dbg_lock_wait rust_dbg_lock_signal rust_dbg_call -rust_frame_address |
