Skip to content

Commit d2a4d60

Browse files
committed
Also handle InstanceKind::LlvmIntrinsic in preempt_count
1 parent 6591904 commit d2a4d60

4 files changed

Lines changed: 43 additions & 22 deletions

File tree

‎Cargo.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ rustc_private = true
3333

3434
[patch.crates-io]
3535
compiletest_rs = { git = "https://github.com/Manishearth/compiletest-rs", rev = "63663557c6a28c645c506f54d08111cf028e1ac8" }
36+
37+
[profile.release]
38+
debug = true

‎src/preempt_count/adjustment.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ memoize!(
584584
} = poly_instance;
585585
match instance.def {
586586
// No Rust built-in intrinsics will mess with preemption count.
587-
ty::InstanceKind::Intrinsic(_) => return Ok(0),
587+
ty::InstanceKind::Intrinsic(_) | ty::InstanceKind::LlvmIntrinsic(_) => return Ok(0),
588588
// Empty drop glue, then it definitely won't mess with preemption count.
589589
ty::InstanceKind::Shim(ty::ShimKind::DropGlue(_, None)) => return Ok(0),
590590
ty::InstanceKind::Shim(ty::ShimKind::DropGlue(_, Some(ty))) => {
@@ -750,7 +750,7 @@ memoize!(
750750

751751
match instance.def {
752752
// No Rust built-in intrinsics will mess with preemption count.
753-
ty::InstanceKind::Intrinsic(_) => return Ok(()),
753+
ty::InstanceKind::Intrinsic(_) | ty::InstanceKind::LlvmIntrinsic(_) => return Ok(()),
754754
// Empty drop glue, then it definitely won't mess with preemption count.
755755
ty::InstanceKind::Shim(ty::ShimKind::DropGlue(_, None)) => return Ok(()),
756756
ty::InstanceKind::Shim(ty::ShimKind::DropGlue(_, Some(ty))) => {

‎src/preempt_count/check.rs‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,14 @@ impl<'mir, 'tcx, 'cx> MirNeighborVisitor<'mir, 'tcx, 'cx> {
162162
let fn_ty = operand.ty(self.body, self.cx.tcx);
163163
let fn_ty = self.monomorphize(fn_ty);
164164
if let ty::FnDef(def_id, args) = *fn_ty.kind() {
165-
let instance =
166-
ty::Instance::try_resolve(self.cx.tcx, self.typing_env, def_id, args.no_bound_vars().unwrap())
167-
.unwrap()
168-
.ok_or(Error::TooGeneric)?;
165+
let instance = ty::Instance::try_resolve(
166+
self.cx.tcx,
167+
self.typing_env,
168+
def_id,
169+
args.no_bound_vars().unwrap(),
170+
)
171+
.unwrap()
172+
.ok_or(Error::TooGeneric)?;
169173
self.check_fn_pointer_cast(instance, span)?;
170174
}
171175
}
@@ -251,10 +255,14 @@ impl<'mir, 'tcx, 'cx> MirNeighborVisitor<'mir, 'tcx, 'cx> {
251255
let callee_ty = self.monomorphize(callee_ty);
252256

253257
if let ty::FnDef(def_id, args) = *callee_ty.kind() {
254-
let instance =
255-
ty::Instance::try_resolve(self.cx.tcx, self.typing_env, def_id, args.no_bound_vars().unwrap())
256-
.unwrap()
257-
.ok_or(Error::TooGeneric)?;
258+
let instance = ty::Instance::try_resolve(
259+
self.cx.tcx,
260+
self.typing_env,
261+
def_id,
262+
args.no_bound_vars().unwrap(),
263+
)
264+
.unwrap()
265+
.ok_or(Error::TooGeneric)?;
258266
self.cx.call_stack.borrow_mut().push(UseSite {
259267
instance: self.typing_env.as_query_input(self.instance),
260268
kind: UseSiteKind::Call(span),
@@ -774,7 +782,7 @@ memoize!(
774782

775783
match instance.def {
776784
// Rust built-in intrinsics does not refer to anything else.
777-
ty::InstanceKind::Intrinsic(_) => return Ok(()),
785+
ty::InstanceKind::Intrinsic(_) | ty::InstanceKind::LlvmIntrinsic(_) => return Ok(()),
778786
// Empty drop glue, then it is a no-op.
779787
ty::InstanceKind::Shim(ty::ShimKind::DropGlue(_, None)) => return Ok(()),
780788
ty::InstanceKind::Shim(ty::ShimKind::DropGlue(_, Some(ty))) => {

‎src/preempt_count/expectation.rs‎

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ impl<'tcx> AnalysisCtxt<'tcx> {
4343
// This also avoids `TooGeneric` when def_id is an trait method.
4444
v
4545
} else {
46-
let callee_instance =
47-
ty::Instance::try_resolve(self.tcx, typing_env, def_id, args.no_bound_vars().unwrap())
48-
.unwrap()
49-
.ok_or(Error::TooGeneric)?;
46+
let callee_instance = ty::Instance::try_resolve(
47+
self.tcx,
48+
typing_env,
49+
def_id,
50+
args.no_bound_vars().unwrap(),
51+
)
52+
.unwrap()
53+
.ok_or(Error::TooGeneric)?;
5054
self.call_stack.borrow_mut().push(UseSite {
5155
instance: typing_env.as_query_input(instance),
5256
kind: UseSiteKind::Call(terminator.source_info.span),
@@ -154,10 +158,14 @@ impl<'tcx> AnalysisCtxt<'tcx> {
154158
diag.note(format!("but the callee expects preemption count {}", v));
155159
return Ok(());
156160
} else {
157-
let callee_instance =
158-
ty::Instance::try_resolve(self.tcx, typing_env, def_id, args.no_bound_vars().unwrap())
159-
.unwrap()
160-
.ok_or(Error::TooGeneric)?;
161+
let callee_instance = ty::Instance::try_resolve(
162+
self.tcx,
163+
typing_env,
164+
def_id,
165+
args.no_bound_vars().unwrap(),
166+
)
167+
.unwrap()
168+
.ok_or(Error::TooGeneric)?;
161169

162170
if !span.has_primary_spans() {
163171
span = self.def_span(callee_instance.def_id()).into();
@@ -267,7 +275,7 @@ impl<'tcx> AnalysisCtxt<'tcx> {
267275
) -> Result<(), Error> {
268276
match instance.def {
269277
// No Rust built-in intrinsics will mess with preemption count.
270-
ty::InstanceKind::Intrinsic(_) => unreachable!(),
278+
ty::InstanceKind::Intrinsic(_) | ty::InstanceKind::LlvmIntrinsic(_) => unreachable!(),
271279
// Empty drop glue, then it definitely won't mess with preemption count.
272280
ty::InstanceKind::Shim(ty::ShimKind::DropGlue(_, None)) => unreachable!(),
273281
ty::InstanceKind::Shim(ty::ShimKind::DropGlue(_, Some(ty))) => {
@@ -929,7 +937,9 @@ memoize!(
929937
} = poly_instance;
930938
match instance.def {
931939
// No Rust built-in intrinsics will mess with preemption count.
932-
ty::InstanceKind::Intrinsic(_) => return Ok(ExpectationRange::top()),
940+
ty::InstanceKind::Intrinsic(_) | ty::InstanceKind::LlvmIntrinsic(_) => {
941+
return Ok(ExpectationRange::top());
942+
}
933943
// Empty drop glue, then it definitely won't mess with preemption count.
934944
ty::InstanceKind::Shim(ty::ShimKind::DropGlue(_, None)) => {
935945
return Ok(ExpectationRange::top());
@@ -1098,7 +1108,7 @@ memoize!(
10981108

10991109
match instance.def {
11001110
// No Rust built-in intrinsics will mess with preemption count.
1101-
ty::InstanceKind::Intrinsic(_) => return Ok(()),
1111+
ty::InstanceKind::Intrinsic(_) | ty::InstanceKind::LlvmIntrinsic(_) => return Ok(()),
11021112
// Empty drop glue, then it definitely won't mess with preemption count.
11031113
ty::InstanceKind::Shim(ty::ShimKind::DropGlue(_, None)) => return Ok(()),
11041114
ty::InstanceKind::Shim(ty::ShimKind::DropGlue(_, Some(ty))) => {

0 commit comments

Comments
 (0)