diff options
| author | Mark Simulacrum <mark.simulacrum@gmail.com> | 2016-12-19 14:10:48 -0700 |
|---|---|---|
| committer | Mark Simulacrum <mark.simulacrum@gmail.com> | 2016-12-20 20:03:35 -0700 |
| commit | 22bf541e27eaea348f1ab534b1ec2f1e701254d5 (patch) | |
| tree | 79ffc26039879fa6f57b7f3478b6670d690959d1 | |
| parent | 5ef85dd57e46e59e8035f522a672eeffba989d05 (diff) | |
| download | rust-22bf541e27eaea348f1ab534b1ec2f1e701254d5.tar.gz rust-22bf541e27eaea348f1ab534b1ec2f1e701254d5.zip | |
Clean up uses of set_personality_fn.
Remove gnu/msvc constructors for Funclet; these are worse for readability than explicit Some/None.
| -rw-r--r-- | src/librustc_trans/cleanup.rs | 4 | ||||
| -rw-r--r-- | src/librustc_trans/common.rs | 10 | ||||
| -rw-r--r-- | src/librustc_trans/mir/block.rs | 4 | ||||
| -rw-r--r-- | src/librustc_trans/mir/mod.rs | 18 |
4 files changed, 12 insertions, 24 deletions
diff --git a/src/librustc_trans/cleanup.rs b/src/librustc_trans/cleanup.rs index 7b655bbd606..4eb786d6394 100644 --- a/src/librustc_trans/cleanup.rs +++ b/src/librustc_trans/cleanup.rs @@ -203,8 +203,8 @@ impl<'tcx> CleanupScope<'tcx> { // Insert cleanup instructions into the cleanup block let funclet = match val { - UnwindKind::CleanupPad(_) => Funclet::msvc(cleanup.cleanup_pad(None, &[])), - UnwindKind::LandingPad => Funclet::gnu(), + UnwindKind::CleanupPad(_) => Some(Funclet::new(cleanup.cleanup_pad(None, &[]))), + UnwindKind::LandingPad => None, }; drop_val.trans(funclet.as_ref(), &cleanup); diff --git a/src/librustc_trans/common.rs b/src/librustc_trans/common.rs index b7f2fabf184..81aba269a8b 100644 --- a/src/librustc_trans/common.rs +++ b/src/librustc_trans/common.rs @@ -466,15 +466,11 @@ pub struct Funclet { } impl Funclet { - pub fn gnu() -> Option<Funclet> { - None - } - - pub fn msvc(cleanuppad: ValueRef) -> Option<Funclet> { - Some(Funclet { + pub fn new(cleanuppad: ValueRef) -> Funclet { + Funclet { cleanuppad: cleanuppad, operand: OperandBundleDef::new("funclet", &[cleanuppad]), - }) + } } pub fn cleanuppad(&self) -> ValueRef { diff --git a/src/librustc_trans/mir/block.rs b/src/librustc_trans/mir/block.rs index 6b6ca1a98a3..7edc3b00532 100644 --- a/src/librustc_trans/mir/block.rs +++ b/src/librustc_trans/mir/block.rs @@ -86,7 +86,6 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { debug!("llblock: creating cleanup trampoline for {:?}", target); let name = &format!("{:?}_cleanup_trampoline_{:?}", bb, target); let trampoline = this.fcx.build_new_block(name); - trampoline.set_personality_fn(this.fcx.eh_personality()); trampoline.cleanup_ret(cp, Some(lltarget)); trampoline.llbb() } @@ -121,9 +120,6 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { if let Some(cleanup_pad) = cleanup_pad { bcx.cleanup_ret(cleanup_pad, None); } else { - let llpersonality = bcx.fcx().eh_personality(); - bcx.set_personality_fn(llpersonality); - let ps = self.get_personality_slot(&bcx); let lp = bcx.load(ps); Lifetime::End.call(&bcx, ps); diff --git a/src/librustc_trans/mir/mod.rs b/src/librustc_trans/mir/mod.rs index 2cb18134040..6041b76d18e 100644 --- a/src/librustc_trans/mir/mod.rs +++ b/src/librustc_trans/mir/mod.rs @@ -303,19 +303,15 @@ pub fn trans_mir<'a, 'tcx: 'a>( // If false, all funclets should be None (which is the default) let funclets: IndexVec<mir::BasicBlock, Option<Funclet>> = mircx.cleanup_kinds.iter_enumerated().map(|(bb, cleanup_kind)| { - let bcx = mircx.build_block(bb); - match *cleanup_kind { - _ if !base::wants_msvc_seh(fcx.ccx.sess()) => None, - CleanupKind::Internal { .. } => { - bcx.set_personality_fn(fcx.eh_personality()); - None + if let CleanupKind::Funclet = *cleanup_kind { + let bcx = mircx.build_block(bb); + bcx.set_personality_fn(fcx.eh_personality()); + if base::wants_msvc_seh(fcx.ccx.sess()) { + return Some(Funclet::new(bcx.cleanup_pad(None, &[]))); } - CleanupKind::Funclet => { - bcx.set_personality_fn(fcx.eh_personality()); - Funclet::msvc(bcx.cleanup_pad(None, &[])) - } - _ => None } + + None }).collect(); let rpo = traversal::reverse_postorder(&mir); |
