Skip to content

Commit 1079e41

Browse files
committed
Move "return" basic block after all other function blocks.
1 parent 6cc3189 commit 1079e41

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/librustc/lib/llvm.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,12 @@ pub mod llvm {
966966
-> BasicBlockRef;
967967
#[fast_ffi]
968968
pub unsafe fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
969+
970+
#[fast_ffi]
971+
pub unsafe fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef, MoveAfter: BasicBlockRef);
972+
973+
#[fast_ffi]
974+
pub unsafe fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef, MoveBefore: BasicBlockRef);
969975

970976
/* Operations on instructions */
971977
#[fast_ffi]

src/librustc/middle/trans/base.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,8 @@ pub fn trans_closure(ccx: @mut CrateContext,
19071907

19081908
finish(bcx);
19091909
cleanup_and_Br(bcx, bcx_top, fcx.llreturn);
1910+
1911+
unsafe { llvm::LLVMMoveBasicBlockAfter(fcx.llreturn, bcx.llbb); }
19101912

19111913
// Insert the mandatory first few basic blocks before lltop.
19121914
finish_fn(fcx, lltop);

0 commit comments

Comments
 (0)