@@ -8,7 +8,7 @@ use rustc_hir::def_id::DefId;
88use rustc_middle:: mir:: {
99 self ,
1010 interpret:: { ConstValue , GlobalId , InterpResult , PointerArithmetic , Scalar } ,
11- BinOp ,
11+ BinOp , NonDivergingIntrinsic ,
1212} ;
1313use rustc_middle:: ty;
1414use rustc_middle:: ty:: layout:: LayoutOf as _;
@@ -530,6 +530,32 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
530530 Ok ( true )
531531 }
532532
533+ pub ( super ) fn emulate_nondiverging_intrinsic (
534+ & mut self ,
535+ intrinsic : & NonDivergingIntrinsic < ' tcx > ,
536+ ) -> InterpResult < ' tcx > {
537+ match intrinsic {
538+ NonDivergingIntrinsic :: Assume ( op) => {
539+ let op = self . eval_operand ( op, None ) ?;
540+ let cond = self . read_scalar ( & op) ?. to_bool ( ) ?;
541+ if !cond {
542+ throw_ub_format ! ( "`assume` called with `false`" ) ;
543+ }
544+ Ok ( ( ) )
545+ }
546+ NonDivergingIntrinsic :: CopyNonOverlapping ( mir:: CopyNonOverlapping {
547+ count,
548+ src,
549+ dst,
550+ } ) => {
551+ let src = self . eval_operand ( src, None ) ?;
552+ let dst = self . eval_operand ( dst, None ) ?;
553+ let count = self . eval_operand ( count, None ) ?;
554+ self . copy_intrinsic ( & src, & dst, & count, /* nonoverlapping */ true )
555+ }
556+ }
557+ }
558+
533559 pub fn exact_div (
534560 & mut self ,
535561 a : & ImmTy < ' tcx , M :: Provenance > ,
0 commit comments