From 458d2ff067261ab646d914123f9c9c496cd612ae Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Wed, 25 Apr 2012 18:53:54 -0700 Subject: [PATCH] Be a bit more cautious about marking things no-throw. --- src/rustc/back/upcall.rs | 46 +++++++++++++++++++--------------- src/rustc/middle/trans/base.rs | 3 --- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/rustc/back/upcall.rs b/src/rustc/back/upcall.rs index d3946a5de14e..78c1403966d7 100644 --- a/src/rustc/back/upcall.rs +++ b/src/rustc/back/upcall.rs @@ -38,11 +38,10 @@ fn declare_upcalls(targ_cfg: @session::config, let mut arg_tys: [TypeRef] = []; for tys.each {|t| arg_tys += [t]; } let fn_ty = T_fn(arg_tys, rv); - let f = base::decl_cdecl_fn(llmod, prefix + name, fn_ty); - if name != "fail" { - base::set_no_unwind(f); - } - ret f; + ret base::decl_cdecl_fn(llmod, prefix + name, fn_ty); + } + fn nothrow(f: ValueRef) -> ValueRef { + base::set_no_unwind(f); f } let d = bind decl(llmod, "upcall_", _, _, _); let dv = bind decl(llmod, "upcall_", _, _, T_void()); @@ -55,35 +54,42 @@ fn declare_upcalls(targ_cfg: @session::config, T_ptr(T_i8()), size_t]), malloc: - d("malloc", [T_ptr(tydesc_type)], T_ptr(T_i8())), + nothrow(d("malloc", [T_ptr(tydesc_type)], + T_ptr(T_i8()))), free: - dv("free", [T_ptr(T_i8())]), + nothrow(dv("free", [T_ptr(T_i8())])), validate_box: - dv("validate_box", [T_ptr(T_i8())]), + nothrow(dv("validate_box", [T_ptr(T_i8())])), shared_malloc: - d("shared_malloc", [size_t], T_ptr(T_i8())), + nothrow(d("shared_malloc", [size_t], T_ptr(T_i8()))), shared_free: - dv("shared_free", [T_ptr(T_i8())]), + nothrow(dv("shared_free", [T_ptr(T_i8())])), shared_realloc: - d("shared_realloc", [T_ptr(T_i8()), size_t], T_ptr(T_i8())), + nothrow(d("shared_realloc", [T_ptr(T_i8()), size_t], + T_ptr(T_i8()))), mark: d("mark", [T_ptr(T_i8())], int_t), vec_grow: - dv("vec_grow", [T_ptr(T_ptr(opaque_vec_t)), int_t]), + nothrow(dv("vec_grow", [T_ptr(T_ptr(opaque_vec_t)), int_t])), str_new_uniq: - d("str_new_uniq", [T_ptr(T_i8()), int_t], T_ptr(opaque_vec_t)), + nothrow(d("str_new_uniq", [T_ptr(T_i8()), int_t], + T_ptr(opaque_vec_t))), str_new_shared: - d("str_new_shared", [T_ptr(T_i8()), int_t], T_ptr(T_i8())), + nothrow(d("str_new_shared", [T_ptr(T_i8()), int_t], + T_ptr(T_i8()))), str_concat: - d("str_concat", [T_ptr(opaque_vec_t), T_ptr(opaque_vec_t)], - T_ptr(opaque_vec_t)), + nothrow(d("str_concat", [T_ptr(opaque_vec_t), + T_ptr(opaque_vec_t)], + T_ptr(opaque_vec_t))), cmp_type: dv("cmp_type", [T_ptr(T_i1()), T_ptr(tydesc_type), - T_ptr(T_ptr(tydesc_type)), T_ptr(T_i8()), T_ptr(T_i8()), + T_ptr(T_ptr(tydesc_type)), T_ptr(T_i8()), + T_ptr(T_i8()), T_i8()]), log_type: - dv("log_type", [T_ptr(tydesc_type), T_ptr(T_i8()), T_i32()]), + dv("log_type", [T_ptr(tydesc_type), + T_ptr(T_i8()), T_i32()]), alloc_c_stack: d("alloc_c_stack", [size_t], T_ptr(T_i8())), call_shim_on_c_stack: @@ -95,9 +101,9 @@ fn declare_upcalls(targ_cfg: @session::config, d("call_shim_on_rust_stack", [T_ptr(T_i8()), T_ptr(T_i8())], int_t), rust_personality: - d("rust_personality", [], T_i32()), + nothrow(d("rust_personality", [], T_i32())), reset_stack_limit: - dv("reset_stack_limit", []) + nothrow(dv("reset_stack_limit", [])) }; } // diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index facaa0761091..88df4687d61e 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -488,9 +488,6 @@ fn declare_generic_glue(ccx: @crate_ctxt, t: ty::t, llfnty: TypeRef, note_unique_llvm_symbol(ccx, fn_nm); let llfn = decl_cdecl_fn(ccx.llmod, fn_nm, llfnty); set_glue_inlining(llfn, t); - if name != "drop" || !ty::type_has_resources(t) { - set_no_unwind(llfn); - } ret llfn; }