Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions compiler/rustc_codegen_ssa/src/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
mergeable_succ: bool,
) -> MergingSucc {
let span = terminator.source_info.span;
let cond = self.codegen_operand(bx, cond).immediate();
let mut cond = self.codegen_operand(bx, cond).immediate();
let mut const_cond = bx.const_to_opt_u128(cond, false).map(|c| c == 1);

// This case can currently arise only from functions marked
Expand All @@ -589,8 +589,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
return helper.funclet_br(self, bx, target, mergeable_succ);
}

// Pass the condition through llvm.expect for branch hinting.
let cond = bx.expect(cond, expected);
// Give the backend a branch hint that hitting the assertion is unlikely,
// but only when optimizations are enabled.
if bx.tcx().sess.opts.optimize != OptLevel::No {
cond = bx.expect(cond, expected);
}

// Create the failure block and the conditional branch to it.
let lltarget = helper.llbb_with_cleanup(self, target);
Expand Down