Skip to content

Commit

Permalink
When a nounwind function has a personality routine, LLVM messes up …
Browse files Browse the repository at this point in the history
….seh directives (happens to `rust_try` in optimized builds). A workaround is to give `rust_try` the `uwtable` attribute.

Also, make sure that the dummy "load from null" instruction inserted by init_function() gets cleaned up.
  • Loading branch information
vadimcn committed Aug 2, 2015
1 parent 6112b22 commit e493027
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/librustc_trans/trans/intrinsic.rs
Expand Up @@ -16,6 +16,7 @@ use llvm::{SequentiallyConsistent, Acquire, Release, AtomicXchg, ValueRef, TypeK
use middle::subst;
use middle::subst::FnSpace;
use trans::adt;
use trans::attributes;
use trans::base::*;
use trans::build::*;
use trans::callee;
Expand Down Expand Up @@ -1189,6 +1190,7 @@ fn trans_gnu_try<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// ret ptr

let rust_try = declare::define_internal_rust_fn(ccx, "__rust_try", try_fn_ty);
attributes::emit_uwtable(rust_try, true);
let catch_pers = match bcx.tcx().lang_items.eh_personality_catch() {
Some(did) => callee::trans_fn_ref(ccx, did, ExprId(0),
bcx.fcx.param_substs).val,
Expand Down Expand Up @@ -1219,6 +1221,7 @@ fn trans_gnu_try<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
AddClause(catch, vals, C_null(Type::i8p(ccx)));
let ptr = ExtractValue(catch, vals, 0);
Ret(catch, ptr, dloc);
fcx.cleanup();

return rust_try
});
Expand Down

0 comments on commit e493027

Please sign in to comment.