From baa52caf83ef82c301e1264f370de5c22fc3c48d Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Fri, 27 Feb 2015 14:18:39 +0200 Subject: [PATCH] Abort creating wrapper fn for multiple inner fns This discovers another class of mis-trans where we wrap multiple native functions into a single wrapper, which is wrong. --- src/librustc_trans/trans/foreign.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/librustc_trans/trans/foreign.rs b/src/librustc_trans/trans/foreign.rs index e87a5865df05..e154bc1d579f 100644 --- a/src/librustc_trans/trans/foreign.rs +++ b/src/librustc_trans/trans/foreign.rs @@ -642,6 +642,11 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, // return r; // } + if llvm::LLVMCountBasicBlocks(llwrapfn) != 0 { + ccx.sess().bug("wrapping a function inside non-empty wrapper, most likely cause is \ + multiple functions being wrapped"); + } + let ptr = "the block\0".as_ptr(); let the_block = llvm::LLVMAppendBasicBlockInContext(ccx.llcx(), llwrapfn, ptr as *const _);