Skip to content

Commit 6e4f772

Browse files
committed
fix backend intrinsic calls in cg_ssa
1 parent adf9251 commit 6e4f772

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
982982

983983
return if let Some(target) = target {
984984
helper.funclet_br(self, bx, target, mergeable_succ)
985+
} else if kind == CallKind::Tail {
986+
let res = bx.load(
987+
bx.backend_type(result.layout),
988+
result.val.llval,
989+
result.val.align,
990+
);
991+
bx.ret(res);
992+
MergingSucc::False
985993
} else {
986994
bx.unreachable();
987995
MergingSucc::False

tests/ui/explicit-tail-calls/intrinsics.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ fn trans((): ()) {
77
unsafe { become std::mem::transmute(()) }
88
}
99

10+
fn cats(x: u64) -> u32 {
11+
become std::intrinsics::ctlz(x)
12+
}
13+
1014
fn main() {
1115
trans(());
16+
assert_eq!(cats(17), 59);
1217
}
1318

0 commit comments

Comments
 (0)