Skip to content

Commit e493027

Browse files
committed
When a nounwind function has a personality routine, LLVM messes up .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.
1 parent 6112b22 commit e493027

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/librustc_trans/trans/intrinsic.rs

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use llvm::{SequentiallyConsistent, Acquire, Release, AtomicXchg, ValueRef, TypeK
1616
use middle::subst;
1717
use middle::subst::FnSpace;
1818
use trans::adt;
19+
use trans::attributes;
1920
use trans::base::*;
2021
use trans::build::*;
2122
use trans::callee;
@@ -1189,6 +1190,7 @@ fn trans_gnu_try<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
11891190
// ret ptr
11901191

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

12231226
return rust_try
12241227
});

0 commit comments

Comments
 (0)