Skip to content

Commit 2f54cdf

Browse files
committed
codegen: match likely/unlikely via intrinsic symbols
1 parent 203c750 commit 2f54cdf

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

crates/rustc_codegen_spirv/src/builder/intrinsics.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_codegen_ssa::traits::{BuilderMethods, IntrinsicCallBuilderMethods};
1515
use rustc_middle::ty::layout::LayoutOf;
1616
use rustc_middle::ty::{FnDef, Instance, Ty, TyKind, TypingEnv};
1717
use rustc_middle::{bug, ty};
18-
use rustc_span::Span;
18+
use rustc_span::{Span, Symbol};
1919
use rustc_span::sym;
2020

2121
fn int_type_width_signed(ty: Ty<'_>, cx: &CodegenCx<'_>) -> Option<(u64, bool)> {
@@ -83,10 +83,13 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
8383
let ret_ty = self.layout_of(sig.output()).spirv_type(self.span(), self);
8484

8585
let value = match name {
86-
// `sym::likely` no longer exists on newer rustc nightlies, but
87-
// the intrinsic name is still `"likely"` in MIR. Ignore both branch
88-
// hint intrinsics for now.
89-
_ if name == sym::unlikely || name.as_str() == "likely" => args[0].immediate(),
86+
// `sym::likely` no longer exists on newer rustc nightlies, but the
87+
// intrinsic item name remains `likely`; ignore hint intrinsics.
88+
_ if self.tcx.is_intrinsic(def_id, sym::unlikely)
89+
|| self.tcx.is_intrinsic(def_id, Symbol::intern("likely")) =>
90+
{
91+
args[0].immediate()
92+
}
9093

9194
sym::breakpoint => {
9295
self.abort();

0 commit comments

Comments
 (0)