@@ -132,6 +132,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
132
132
llargs : & [ Bx :: Value ] ,
133
133
destination : Option < ( ReturnDest < ' tcx , Bx :: Value > , mir:: BasicBlock ) > ,
134
134
cleanup : Option < mir:: BasicBlock > ,
135
+ argument_tmps : & [ PlaceRef < ' tcx , <Bx as BackendTypes >:: Value > ] ,
135
136
) {
136
137
// If there is a cleanup block and the function we're calling can unwind, then
137
138
// do an invoke, otherwise do a call.
@@ -172,6 +173,9 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
172
173
if let Some ( ( ret_dest, target) ) = destination {
173
174
bx. switch_to_block ( fx. llbb ( target) ) ;
174
175
fx. set_debug_loc ( bx, self . terminator . source_info ) ;
176
+ for tmp in argument_tmps {
177
+ bx. lifetime_end ( tmp. llval , tmp. layout . size ) ;
178
+ }
175
179
fx. store_return ( bx, ret_dest, & fn_abi. ret , invokeret) ;
176
180
}
177
181
} else {
@@ -186,6 +190,9 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
186
190
}
187
191
188
192
if let Some ( ( ret_dest, target) ) = destination {
193
+ for tmp in argument_tmps {
194
+ bx. lifetime_end ( tmp. llval , tmp. layout . size ) ;
195
+ }
189
196
fx. store_return ( bx, ret_dest, & fn_abi. ret , llret) ;
190
197
self . funclet_br ( fx, bx, target) ;
191
198
} else {
@@ -415,6 +422,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
415
422
args,
416
423
Some ( ( ReturnDest :: Nothing , target) ) ,
417
424
unwind,
425
+ & [ ] ,
418
426
) ;
419
427
}
420
428
@@ -492,7 +500,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
492
500
let ( fn_abi, llfn) = common:: build_langcall ( & bx, Some ( span) , lang_item) ;
493
501
494
502
// Codegen the actual panic invoke/call.
495
- helper. do_call ( self , & mut bx, fn_abi, llfn, & args, None , cleanup) ;
503
+ helper. do_call ( self , & mut bx, fn_abi, llfn, & args, None , cleanup, & [ ] ) ;
496
504
}
497
505
498
506
fn codegen_abort_terminator (
@@ -508,7 +516,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
508
516
let ( fn_abi, llfn) = common:: build_langcall ( & bx, Some ( span) , LangItem :: PanicNoUnwind ) ;
509
517
510
518
// Codegen the actual panic invoke/call.
511
- helper. do_call ( self , & mut bx, fn_abi, llfn, & [ ] , None , None ) ;
519
+ helper. do_call ( self , & mut bx, fn_abi, llfn, & [ ] , None , None , & [ ] ) ;
512
520
}
513
521
514
522
/// Returns `true` if this is indeed a panic intrinsic and codegen is done.
@@ -579,6 +587,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
579
587
& [ msg. 0 , msg. 1 , location] ,
580
588
target. as_ref ( ) . map ( |bb| ( ReturnDest :: Nothing , * bb) ) ,
581
589
cleanup,
590
+ & [ ] ,
582
591
) ;
583
592
} else {
584
593
// a NOP
@@ -786,6 +795,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
786
795
( args, None )
787
796
} ;
788
797
798
+ let mut argument_tmps = vec ! [ ] ;
789
799
' make_args: for ( i, arg) in first_args. iter ( ) . enumerate ( ) {
790
800
let mut op = self . codegen_operand ( & mut bx, arg) ;
791
801
@@ -851,8 +861,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
851
861
( & mir:: Operand :: Copy ( _) , Ref ( _, None , _) )
852
862
| ( & mir:: Operand :: Constant ( _) , Ref ( _, None , _) ) => {
853
863
let tmp = PlaceRef :: alloca ( & mut bx, op. layout ) ;
864
+ bx. lifetime_start ( tmp. llval , tmp. layout . size ) ;
854
865
op. val . store ( & mut bx, tmp) ;
855
866
op. val = Ref ( tmp. llval , None , tmp. align ) ;
867
+ argument_tmps. push ( tmp) ;
856
868
}
857
869
_ => { }
858
870
}
@@ -925,6 +937,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
925
937
& llargs,
926
938
target. as_ref ( ) . map ( |& target| ( ret_dest, target) ) ,
927
939
cleanup,
940
+ & argument_tmps,
928
941
) ;
929
942
930
943
bx. switch_to_block ( bb_fail) ;
@@ -942,6 +955,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
942
955
& llargs,
943
956
target. as_ref ( ) . map ( |& target| ( ret_dest, target) ) ,
944
957
cleanup,
958
+ & argument_tmps,
945
959
) ;
946
960
}
947
961
0 commit comments