Skip to content

Commit 10533dd

Browse files
committed
Dedup some intrinsic handling code for caller_location
1 parent a914f90 commit 10533dd

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

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

881-
if matches!(intrinsic, Some(ty::IntrinsicDef { name: sym::caller_location, .. })) {
882-
return if let Some(target) = target {
883-
let location =
884-
self.get_caller_location(bx, mir::SourceInfo { span: fn_span, ..source_info });
885-
886-
let mut llargs = Vec::with_capacity(arg_count);
887-
let ret_dest = self.make_return_dest(
888-
bx,
889-
destination,
890-
&fn_abi.ret,
891-
&mut llargs,
892-
intrinsic,
893-
Some(target),
894-
);
895-
assert_eq!(llargs, []);
896-
if let ReturnDest::IndirectOperand(tmp, _) = ret_dest {
897-
location.val.store(bx, tmp);
898-
}
899-
self.store_return(bx, ret_dest, &fn_abi.ret, location.immediate());
900-
helper.funclet_br(self, bx, target, mergeable_succ)
901-
} else {
902-
MergingSucc::False
903-
};
904-
}
905-
906881
let instance = match intrinsic {
907882
None => instance,
908883
Some(intrinsic) => {
@@ -947,6 +922,18 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
947922
})
948923
.collect();
949924

925+
if matches!(intrinsic, ty::IntrinsicDef { name: sym::caller_location, .. }) {
926+
let location = self
927+
.get_caller_location(bx, mir::SourceInfo { span: fn_span, ..source_info });
928+
929+
assert_eq!(llargs, []);
930+
if let ReturnDest::IndirectOperand(tmp, _) = ret_dest {
931+
location.val.store(bx, tmp);
932+
}
933+
self.store_return(bx, ret_dest, &fn_abi.ret, location.immediate());
934+
return helper.funclet_br(self, bx, target.unwrap(), mergeable_succ);
935+
}
936+
950937
let instance = *instance.as_ref().unwrap();
951938
match Self::codegen_intrinsic_call(bx, instance, fn_abi, &args, dest, span) {
952939
Ok(()) => {

0 commit comments

Comments
 (0)