Skip to content

Commit e927df1

Browse files
committed
Remove spawn_wrap and main_wrap kludges
This isn't needed now that our functions are cdecl (and was apparently only still working by accident). Issue #992
1 parent 243c5c3 commit e927df1

File tree

5 files changed

+10
-41
lines changed

5 files changed

+10
-41
lines changed

src/comp/middle/trans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5662,7 +5662,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
56625662
let llfty = type_of_fn(ccx, sp, ast::proto_fn, false, false,
56635663
[vecarg_ty], nt, 0u);
56645664
let llfdecl = decl_fn(ccx.llmod, "_rust_main",
5665-
lib::llvm::LLVMFastCallConv, llfty);
5665+
lib::llvm::LLVMCCallConv, llfty);
56665666

56675667
let fcx = new_fn_ctxt(new_local_ctxt(ccx), sp, llfdecl);
56685668

src/rt/main.ll.in

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,9 @@
1616

1717
declare i32 @rust_start(i32, i32, i32, i32)
1818

19-
declare external fastcc void @_rust_main(i1* nocapture, %task*, %2* nocapture, %vec*)
20-
21-
define void @_rust_main_wrap(i1* nocapture, %task *, %2* nocapture, %vec *)
22-
{
23-
tail call fastcc void @_rust_main(i1* %0, %task *%1, %2* nocapture %2, %vec* %3)
24-
ret void
25-
}
26-
27-
%nullary_fn = type void (i1*, %task*, %2*)
28-
29-
define void @_rust_spawn_wrap(
30-
i1* nocapture, %task*, %2* nocapture, %nullary_fn* %f)
31-
{
32-
call void %f(i1* %0, %task *%1, %2* nocapture %2)
33-
ret void
34-
}
35-
36-
declare external void @set_spawn_wrapper(void (i1*, %task*, %2*, %nullary_fn*)*);
19+
declare external void @_rust_main(i1* nocapture, %task*, %2* nocapture, %vec*)
3720

3821
define i32 @"MAIN"(i32, i32) {
39-
call void @set_spawn_wrapper(void (i1*, %task*, %2*, %nullary_fn*)* @_rust_spawn_wrap)
40-
41-
%result = tail call i32 @rust_start(i32 ptrtoint (void (i1*, %task*, %2*, %vec*)* @_rust_main_wrap to i32), i32 %0, i32 %1, i32 ptrtoint (%0* @_rust_crate_map_toplevel to i32))
22+
%result = tail call i32 @rust_start(i32 ptrtoint (void (i1*, %task*, %2*, %vec*)* @_rust_main to i32), i32 %0, i32 %1, i32 ptrtoint (%0* @_rust_crate_map_toplevel to i32))
4223
ret i32 %result
4324
}

src/rt/rust_builtin.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,18 @@ struct fn_env_pair {
472472
intptr_t env;
473473
};
474474

475-
extern "C" CDECL uintptr_t get_spawn_wrapper();
475+
// FIXME This is probably not needed at all anymore. Have to rearrange some
476+
// argument passing to remove it.
477+
void rust_spawn_wrapper(void* retptr, rust_task* taskptr, void* envptr,
478+
void(*func)(void*, rust_task*, void*)) {
479+
func(retptr, taskptr, envptr);
480+
}
476481

477482
extern "C" CDECL void
478483
start_task(void *unused_task, rust_task_id id, fn_env_pair *f) {
479484
rust_task *task = rust_scheduler::get_task();
480485
rust_task *target = task->kernel->get_task_by_id(id);
481-
target->start(get_spawn_wrapper(), f->f, f->env);
486+
target->start((uintptr_t)rust_spawn_wrapper, f->f, f->env);
482487
target->deref();
483488
}
484489

src/rt/rust_task.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -180,22 +180,6 @@ void task_start_wrapper(spawn_args *a)
180180
}
181181
}
182182

183-
/* We spawn a rust (fastcc) function through a CDECL function
184-
defined in main.ll, which is built as part of each crate. These accessors
185-
allow each rust program to install that function at startup */
186-
187-
uintptr_t spawn_wrapper;
188-
189-
extern "C" CDECL void
190-
set_spawn_wrapper(uintptr_t f) {
191-
spawn_wrapper = f;
192-
}
193-
194-
extern "C" CDECL uintptr_t
195-
get_spawn_wrapper() {
196-
return spawn_wrapper;
197-
}
198-
199183
void
200184
rust_task::start(uintptr_t spawnee_fn,
201185
uintptr_t args,

src/rt/rustrt.def.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ rust_run_program
5454
rust_start
5555
rust_getcwd
5656
set_min_stack
57-
set_spawn_wrapper
5857
sched_threads
5958
size_of
6059
squareroot

0 commit comments

Comments
 (0)