mirror of https://github.com/rust-lang/rust.git
Auto merge of #124606 - scottmcm:less-expect, r=cjgillot
Stop `llvm.expect`ing assert terminators We're putting `llvm.expect` calls before the <https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.TerminatorKind.html#variant.Assert> terminators. But we don't need them. One of the arms is always to a panic function that's marked `#[cold]`, which is `cold` <https://llvm.org/docs/LangRef.html#function-attributes> in LLVM, which > When computing edge weights, basic blocks post-dominated by a cold function call are also considered to be cold; and, thus, given low weight. So even without us emitting the extra intrinsic call, LLVM knows what to expect for the `br`. Thus we can save the (small) effort of emitting it and then LLVM optimizing it out. r? compiler
This commit is contained in:
commit
02f7806ecd
|
@ -649,8 +649,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
return helper.funclet_br(self, bx, target, mergeable_succ);
|
return helper.funclet_br(self, bx, target, mergeable_succ);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass the condition through llvm.expect for branch hinting.
|
// Because we're branching to a panic block (either a `#[cold]` one
|
||||||
let cond = bx.expect(cond, expected);
|
// or an inlined abort), there's no need to `expect` it.
|
||||||
|
|
||||||
// Create the failure block and the conditional branch to it.
|
// Create the failure block and the conditional branch to it.
|
||||||
let lltarget = helper.llbb_with_cleanup(self, target);
|
let lltarget = helper.llbb_with_cleanup(self, target);
|
||||||
|
|
Loading…
Reference in New Issue