Skip to content

Commit e32eb4c

Browse files
committed
Dedup some intrinsic handling code for caller_location
1 parent 98e8601 commit e32eb4c

File tree

1 file changed

+12
-25
lines changed
  • compiler/rustc_codegen_ssa/src/mir

1 file changed

+12
-25
lines changed

compiler/rustc_codegen_ssa/src/mir/block.rs

+12-25
Original file line numberDiff line numberDiff line change
@@ -902,31 +902,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
902902
// The arguments we'll be passing. Plus one to account for outptr, if used.
903903
let arg_count = fn_abi.args.len() + fn_abi.ret.is_indirect() as usize;
904904

905-
if matches!(intrinsic, Some(ty::IntrinsicDef { name: sym::caller_location, .. })) {
906-
return if let Some(target) = target {
907-
let location =
908-
self.get_caller_location(bx, mir::SourceInfo { span: fn_span, ..source_info });
909-
910-
let mut llargs = Vec::with_capacity(arg_count);
911-
let ret_dest = self.make_return_dest(
912-
bx,
913-
destination,
914-
&fn_abi.ret,
915-
&mut llargs,
916-
intrinsic,
917-
Some(target),
918-
);
919-
assert_eq!(llargs, []);
920-
if let ReturnDest::IndirectOperand(tmp, _) = ret_dest {
921-
location.val.store(bx, tmp);
922-
}
923-
self.store_return(bx, ret_dest, &fn_abi.ret, location.immediate());
924-
helper.funclet_br(self, bx, target, mergeable_succ)
925-
} else {
926-
MergingSucc::False
927-
};
928-
}
929-
930905
let instance = match intrinsic {
931906
None => instance,
932907
Some(intrinsic) => {
@@ -971,6 +946,18 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
971946
})
972947
.collect();
973948

949+
if matches!(intrinsic, ty::IntrinsicDef { name: sym::caller_location, .. }) {
950+
let location = self
951+
.get_caller_location(bx, mir::SourceInfo { span: fn_span, ..source_info });
952+
953+
assert_eq!(llargs, []);
954+
if let ReturnDest::IndirectOperand(tmp, _) = ret_dest {
955+
location.val.store(bx, tmp);
956+
}
957+
self.store_return(bx, ret_dest, &fn_abi.ret, location.immediate());
958+
return helper.funclet_br(self, bx, target.unwrap(), mergeable_succ);
959+
}
960+
974961
let instance = *instance.as_ref().unwrap();
975962
match Self::codegen_intrinsic_call(bx, instance, fn_abi, &args, dest, span) {
976963
Ok(()) => {

0 commit comments

Comments
 (0)