arr.len() as libc::size_t);
}
+ if sess.no_landing_pads() {
+ unsafe {
+ llvm::LLVMRustMarkAllFunctionsNounwind(llmod);
+ }
+ }
+
// Now we have one massive module inside of llmod. Time to run the
// LTO-specific optimization passes that LLVM provides.
//
pub fn lto(&self) -> bool {
self.debugging_opt(lto)
}
+ pub fn no_landing_pads(&self) -> bool {
+ self.debugging_opt(no_landing_pads)
+ }
// pointless function, now...
pub fn str_of(&self, id: ast::Ident) -> @str {
pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
syms: **c_char,
len: size_t);
+ pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
}
}
}
pub fn need_invoke(bcx: @mut Block) -> bool {
- if (bcx.ccx().sess.opts.debugging_opts & session::no_landing_pads != 0) {
+ if bcx.ccx().sess.no_landing_pads() {
return false;
}
let _icx = push_ctxt("trans_block_cleanups");
// NB: Don't short-circuit even if this block is unreachable because
// GC-based cleanup needs to the see that the roots are live.
- let no_lpads =
- bcx.ccx().sess.opts.debugging_opts & session::no_landing_pads != 0;
+ let no_lpads = bcx.ccx().sess.no_landing_pads();
if bcx.unreachable && !no_lpads { return bcx; }
let mut bcx = bcx;
for cu in cleanups.rev_iter() {
use back::abi;
use back::link::*;
-use driver::session;
use lib;
use lib::llvm::{llvm, ValueRef, True};
use middle::lang_items::{FreeFnLangItem, ExchangeFreeFnLangItem};
let ccx = bcx.ccx();
// NB: Don't short-circuit even if this block is unreachable because
// GC-based cleanup needs to the see that the roots are live.
- let no_lpads = ccx.sess.opts.debugging_opts & session::no_landing_pads != 0;
- if bcx.unreachable && !no_lpads { return; }
+ if bcx.unreachable && !ccx.sess.no_landing_pads() { return; }
let static_glue_fn = match static_ti {
None => None,
passes.add(llvm::createInternalizePass(ref));
passes.run(*unwrap(M));
}
+
+extern "C" void
+LLVMRustMarkAllFunctionsNounwind(LLVMModuleRef M) {
+ for (Module::iterator GV = unwrap(M)->begin(),
+ E = unwrap(M)->end(); GV != E; ++GV) {
+ GV->setDoesNotThrow();
+ Function *F = dyn_cast<Function>(GV);
+ if (F == NULL)
+ continue;
+
+ for (Function::iterator B = F->begin(), BE = F->end(); B != BE; ++B) {
+ for (BasicBlock::iterator I = B->begin(), IE = B->end();
+ I != IE; ++I) {
+ if (isa<InvokeInst>(I)) {
+ InvokeInst *CI = cast<InvokeInst>(I);
+ CI->setDoesNotThrow();
+ }
+ }
+ }
+ }
+}