diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index a367de059b8..81d5efa6314 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -966,6 +966,12 @@ pub mod llvm { -> BasicBlockRef; #[fast_ffi] pub unsafe fn LLVMDeleteBasicBlock(BB: BasicBlockRef); + + #[fast_ffi] + pub unsafe fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef, MoveAfter: BasicBlockRef); + + #[fast_ffi] + pub unsafe fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef, MoveBefore: BasicBlockRef); /* Operations on instructions */ #[fast_ffi] diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 580e7fa1900..70b6c2ba036 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1907,6 +1907,8 @@ pub fn trans_closure(ccx: @mut CrateContext, finish(bcx); cleanup_and_Br(bcx, bcx_top, fcx.llreturn); + + unsafe { llvm::LLVMMoveBasicBlockAfter(fcx.llreturn, bcx.llbb); } // Insert the mandatory first few basic blocks before lltop. finish_fn(fcx, lltop);