|
1 | 1 | use rustc_abi::Size;
|
2 |
| -use rustc_const_eval::interpret::{InterpCx, InterpResult, interp_ok}; |
3 |
| -use rustc_middle::mir::{Terminator, TerminatorKind}; |
4 |
| -use rustc_middle::ty::{self, ScalarInt, Ty}; |
| 2 | +use rustc_const_eval::interpret::{InterpResult, interp_ok}; |
| 3 | +use rustc_middle::ty::ScalarInt; |
5 | 4 | use tracing::info;
|
6 | 5 |
|
7 | 6 | use super::GenmcScalar;
|
8 | 7 | use crate::alloc_addresses::EvalContextExt as _;
|
9 |
| -use crate::{ |
10 |
| - BorTag, MiriInterpCx, MiriMachine, Pointer, Provenance, Scalar, ThreadId, throw_unsup_format, |
11 |
| -}; |
| 8 | +use crate::{BorTag, MiriInterpCx, Pointer, Provenance, Scalar, throw_unsup_format}; |
12 | 9 |
|
13 | 10 | pub fn split_access(address: Size, size: Size) -> impl Iterator<Item = (u64, u64)> {
|
14 | 11 | /// Maximum size memory access in bytes that GenMC supports.
|
@@ -147,53 +144,3 @@ pub fn genmc_scalar_to_scalar<'tcx>(
|
147 | 144 | let value_scalar_int = ScalarInt::try_from_uint(trunc_value, size).unwrap();
|
148 | 145 | interp_ok(Scalar::Int(value_scalar_int))
|
149 | 146 | }
|
150 |
| - |
151 |
| -pub fn is_terminator_atomic<'tcx>( |
152 |
| - ecx: &InterpCx<'tcx, MiriMachine<'tcx>>, |
153 |
| - terminator: &Terminator<'tcx>, |
154 |
| - thread_id: ThreadId, |
155 |
| -) -> InterpResult<'tcx, bool> { |
156 |
| - match &terminator.kind { |
157 |
| - // All atomics are modeled as function calls to intrinsic functions. |
158 |
| - // The one exception is thread joining, but those are also calls. |
159 |
| - TerminatorKind::Call { func, .. } | TerminatorKind::TailCall { func, .. } => { |
160 |
| - let frame = ecx.machine.threads.get_thread_stack(thread_id).last().unwrap(); |
161 |
| - let func_ty = func.ty(&frame.body().local_decls, *ecx.tcx); |
162 |
| - info!("GenMC: terminator is a call with operand: {func:?}, ty of operand: {func_ty:?}"); |
163 |
| - |
164 |
| - is_function_atomic(ecx, func_ty) |
165 |
| - } |
166 |
| - _ => interp_ok(false), |
167 |
| - } |
168 |
| -} |
169 |
| - |
170 |
| -fn is_function_atomic<'tcx>( |
171 |
| - ecx: &InterpCx<'tcx, MiriMachine<'tcx>>, |
172 |
| - func_ty: Ty<'tcx>, |
173 |
| - // func: &Operand<'tcx>, |
174 |
| -) -> InterpResult<'tcx, bool> { |
175 |
| - let callee_def_id = match func_ty.kind() { |
176 |
| - ty::FnDef(def_id, _args) => def_id, |
177 |
| - _ => return interp_ok(true), // we don't know the callee, might be an intrinsic or pthread_join |
178 |
| - }; |
179 |
| - if ecx.tcx.is_foreign_item(*callee_def_id) { |
180 |
| - // Some shims, like pthread_join, must be considered loads. So just consider them all loads, |
181 |
| - // these calls are not *that* common. |
182 |
| - return interp_ok(true); |
183 |
| - } |
184 |
| - |
185 |
| - let Some(intrinsic_def) = ecx.tcx.intrinsic(callee_def_id) else { |
186 |
| - // TODO GENMC: Make this work for other platforms? |
187 |
| - let item_name = ecx.tcx.item_name(*callee_def_id); |
188 |
| - info!("GenMC: function DefId: {callee_def_id:?}, item name: {item_name:?}"); |
189 |
| - if matches!(item_name.as_str(), "pthread_join" | "WaitForSingleObject") { |
190 |
| - info!("GenMC: found a 'join' terminator: '{}'", item_name.as_str(),); |
191 |
| - return interp_ok(true); |
192 |
| - } |
193 |
| - return interp_ok(false); |
194 |
| - }; |
195 |
| - let intrinsice_name = intrinsic_def.name.as_str(); |
196 |
| - info!("GenMC: intrinsic name: '{intrinsice_name}'"); |
197 |
| - // TODO GENMC(ENHANCEMENT): make this more precise (only loads). How can we make this maintainable? |
198 |
| - interp_ok(intrinsice_name.starts_with("atomic_")) |
199 |
| -} |
0 commit comments