Skip to content

Commit 015cf74

Browse files
committed
---
yaml --- r: 228124 b: refs/heads/try c: 3e26e56 h: refs/heads/master v: v3
1 parent 73f33c6 commit 015cf74

File tree

4 files changed

+58
-7
lines changed

4 files changed

+58
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 83ee47b054deb5939be20d7d6ce03ad33d005424
4+
refs/heads/try: 3e26e56a79ae33dfc8f2f4d0123b5080fd0a7853
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustc_trans/trans/base.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,14 @@ pub fn invoke<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
752752

753753
pub fn need_invoke(bcx: Block) -> bool {
754754
if bcx.sess().no_landing_pads() {
755-
return false;
755+
return false
756+
}
757+
758+
// Currently 32-bit MSVC unwinding is not super well implemented in LLVM, so
759+
// we avoid it entirely.
760+
if bcx.sess().target.target.options.is_like_msvc &&
761+
bcx.sess().target.target.arch == "x86" {
762+
return false
756763
}
757764

758765
// Avoid using invoke if we are already inside a landing pad.

branches/try/src/librustc_trans/trans/cleanup.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,8 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx
851851
// an "exception", but for MSVC we want to force SEH. This means that we
852852
// can't actually have the personality function be our standard
853853
// `rust_eh_personality` function, but rather we wired it up to the
854-
// CRT's custom `__C_specific_handler` personality funciton, which
855-
// forces LLVM to consider landing pads as "landing pads for SEH".
854+
// CRT's custom personality function, which forces LLVM to consider
855+
// landing pads as "landing pads for SEH".
856856
let target = &self.ccx.sess().target.target;
857857
let llpersonality = match pad_bcx.tcx().lang_items.eh_personality() {
858858
Some(def_id) if !target.options.is_like_msvc => {
@@ -864,10 +864,12 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx
864864
match *personality {
865865
Some(llpersonality) => llpersonality,
866866
None => {
867-
let name = if target.options.is_like_msvc {
868-
"__C_specific_handler"
869-
} else {
867+
let name = if !target.options.is_like_msvc {
870868
"rust_eh_personality"
869+
} else if target.arch == "x86" {
870+
"_except_handler3"
871+
} else {
872+
"__C_specific_handler"
871873
};
872874
let fty = Type::variadic_func(&[], &Type::i32(self.ccx));
873875
let f = declare::declare_cfn(self.ccx, name, fty,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
; Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
; file at the top-level directory of this distribution and at
3+
; http://rust-lang.org/COPYRIGHT.
4+
;
5+
; Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
; http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
; <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
; option. This file may not be copied, modified, or distributed
9+
; except according to those terms.
10+
11+
; For more comments about what's going on here see rust_try_msvc_64.ll. The only
12+
; difference between that and this file is the personality function used as it's
13+
; different for 32-bit MSVC than it is for 64-bit.
14+
15+
define i8* @rust_try(void (i8*)* %f, i8* %env)
16+
personality i8* bitcast (i32 (...)* @_except_handler3 to i8*)
17+
{
18+
invoke void %f(i8* %env)
19+
to label %normal
20+
unwind label %catch
21+
22+
normal:
23+
ret i8* null
24+
catch:
25+
%vals = landingpad { i8*, i32 }
26+
catch i8* bitcast (i32 (i8*, i8*)* @__rust_try_filter to i8*)
27+
%ehptr = extractvalue { i8*, i32 } %vals, 0
28+
%sel = extractvalue { i8*, i32 } %vals, 1
29+
%filter_sel = call i32 @llvm.eh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @__rust_try_filter to i8*))
30+
%is_filter = icmp eq i32 %sel, %filter_sel
31+
br i1 %is_filter, label %catch-return, label %catch-resume
32+
33+
catch-return:
34+
ret i8* %ehptr
35+
36+
catch-resume:
37+
resume { i8*, i32 } %vals
38+
}
39+
40+
declare i32 @_except_handler3(...)
41+
declare i32 @__rust_try_filter(i8*, i8*)
42+
declare i32 @llvm.eh.typeid.for(i8*) readnone nounwind

0 commit comments

Comments
 (0)