Skip to content

Commit 3afa1d6

Browse files
committed
Sync from rust 56e7678
2 parents fa76604 + 16ed191 commit 3afa1d6

File tree

4 files changed

+37
-33
lines changed

4 files changed

+37
-33
lines changed

src/base.rs

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -794,20 +794,31 @@ fn codegen_stmt<'tcx>(
794794
| StatementKind::AscribeUserType(..) => {}
795795

796796
StatementKind::Coverage { .. } => fx.tcx.sess.fatal("-Zcoverage is unimplemented"),
797-
StatementKind::CopyNonOverlapping(inner) => {
798-
let dst = codegen_operand(fx, &inner.dst);
799-
let pointee = dst
800-
.layout()
801-
.pointee_info_at(fx, rustc_target::abi::Size::ZERO)
802-
.expect("Expected pointer");
803-
let dst = dst.load_scalar(fx);
804-
let src = codegen_operand(fx, &inner.src).load_scalar(fx);
805-
let count = codegen_operand(fx, &inner.count).load_scalar(fx);
806-
let elem_size: u64 = pointee.size.bytes();
807-
let bytes =
808-
if elem_size != 1 { fx.bcx.ins().imul_imm(count, elem_size as i64) } else { count };
809-
fx.bcx.call_memcpy(fx.target_config, dst, src, bytes);
810-
}
797+
StatementKind::Intrinsic(ref intrinsic) => match &**intrinsic {
798+
// We ignore `assume` intrinsics, they are only useful for optimizations
799+
NonDivergingIntrinsic::Assume(_) => {}
800+
NonDivergingIntrinsic::CopyNonOverlapping(mir::CopyNonOverlapping {
801+
src,
802+
dst,
803+
count,
804+
}) => {
805+
let dst = codegen_operand(fx, dst);
806+
let pointee = dst
807+
.layout()
808+
.pointee_info_at(fx, rustc_target::abi::Size::ZERO)
809+
.expect("Expected pointer");
810+
let dst = dst.load_scalar(fx);
811+
let src = codegen_operand(fx, src).load_scalar(fx);
812+
let count = codegen_operand(fx, count).load_scalar(fx);
813+
let elem_size: u64 = pointee.size.bytes();
814+
let bytes = if elem_size != 1 {
815+
fx.bcx.ins().imul_imm(count, elem_size as i64)
816+
} else {
817+
count
818+
};
819+
fx.bcx.call_memcpy(fx.target_config, dst, src, bytes);
820+
}
821+
},
811822
}
812823
}
813824

src/constant.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,11 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
536536
{
537537
return None;
538538
}
539-
StatementKind::CopyNonOverlapping(_) => {
540-
return None;
541-
} // conservative handling
539+
StatementKind::Intrinsic(ref intrinsic) => match **intrinsic {
540+
NonDivergingIntrinsic::CopyNonOverlapping(..) => return None,
541+
NonDivergingIntrinsic::Assume(..) => {}
542+
},
543+
// conservative handling
542544
StatementKind::Assign(_)
543545
| StatementKind::FakeRead(_)
544546
| StatementKind::SetDiscriminant { .. }

src/discriminant.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ pub(crate) fn codegen_set_discriminant<'tcx>(
4242
Variants::Multiple {
4343
tag: _,
4444
tag_field,
45-
tag_encoding: TagEncoding::Niche { dataful_variant, ref niche_variants, niche_start },
45+
tag_encoding: TagEncoding::Niche { untagged_variant, ref niche_variants, niche_start },
4646
variants: _,
4747
} => {
48-
if variant_index != dataful_variant {
48+
if variant_index != untagged_variant {
4949
let niche = place.place_field(fx, mir::Field::new(tag_field));
5050
let niche_value = variant_index.as_u32() - niche_variants.start().as_u32();
5151
let niche_value = ty::ScalarInt::try_from_uint(
@@ -113,7 +113,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
113113
let res = CValue::by_val(val, dest_layout);
114114
dest.write_cvalue(fx, res);
115115
}
116-
TagEncoding::Niche { dataful_variant, ref niche_variants, niche_start } => {
116+
TagEncoding::Niche { untagged_variant, ref niche_variants, niche_start } => {
117117
// Rebase from niche values to discriminants, and check
118118
// whether the result is in range for the niche variants.
119119

@@ -169,8 +169,9 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
169169
fx.bcx.ins().iadd_imm(relative_discr, i64::from(niche_variants.start().as_u32()))
170170
};
171171

172-
let dataful_variant = fx.bcx.ins().iconst(cast_to, i64::from(dataful_variant.as_u32()));
173-
let discr = fx.bcx.ins().select(is_niche, niche_discr, dataful_variant);
172+
let untagged_variant =
173+
fx.bcx.ins().iconst(cast_to, i64::from(untagged_variant.as_u32()));
174+
let discr = fx.bcx.ins().select(is_niche, niche_discr, untagged_variant);
174175
let res = CValue::by_val(discr, dest_layout);
175176
dest.write_cvalue(fx, res);
176177
}

src/intrinsics/mod.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,6 @@ fn codegen_regular_intrinsic_call<'tcx>(
381381
let usize_layout = fx.layout_of(fx.tcx.types.usize);
382382

383383
match intrinsic {
384-
sym::assume => {
385-
intrinsic_args!(fx, args => (_a); intrinsic);
386-
}
387384
sym::likely | sym::unlikely => {
388385
intrinsic_args!(fx, args => (a); intrinsic);
389386

@@ -813,20 +810,13 @@ fn codegen_regular_intrinsic_call<'tcx>(
813810
ret.write_cvalue(fx, val);
814811
}
815812

816-
sym::ptr_guaranteed_eq => {
813+
sym::ptr_guaranteed_cmp => {
817814
intrinsic_args!(fx, args => (a, b); intrinsic);
818815

819816
let val = crate::num::codegen_ptr_binop(fx, BinOp::Eq, a, b);
820817
ret.write_cvalue(fx, val);
821818
}
822819

823-
sym::ptr_guaranteed_ne => {
824-
intrinsic_args!(fx, args => (a, b); intrinsic);
825-
826-
let val = crate::num::codegen_ptr_binop(fx, BinOp::Ne, a, b);
827-
ret.write_cvalue(fx, val);
828-
}
829-
830820
sym::caller_location => {
831821
intrinsic_args!(fx, args => (); intrinsic);
832822

0 commit comments

Comments
 (0)