Skip to content

Commit

Permalink
trans: don't create allocas anywhere other than the entry block.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Jun 7, 2016
1 parent 11e3109 commit 02cbc0e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/librustc_trans/mir/block.rs
Expand Up @@ -894,8 +894,11 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
// bitcasting to the struct type yields invalid cast errors.

// We instead thus allocate some scratch space...
let llscratch = bcx.alloca(llcast_ty, "fn_ret_cast");
bcx.with_block(|bcx| base::call_lifetime_start(bcx, llscratch));
let llscratch = bcx.with_block(|bcx| {
let alloca = base::alloca(bcx, llcast_ty, "fn_ret_cast");
base::call_lifetime_start(bcx, alloca);
alloca
});

// ...where we first store the value...
bcx.store(op.immediate(), llscratch);
Expand Down

0 comments on commit 02cbc0e

Please sign in to comment.