@@ -704,23 +704,22 @@ pub struct VClockAlloc {
704
704
impl VClockAlloc {
705
705
/// Create a new data-race detector for newly allocated memory.
706
706
pub fn new_allocation ( global : & MemoryExtra , len : Size , kind : MemoryKind < MiriMemoryKind > ) -> VClockAlloc {
707
- let track_alloc = match kind {
707
+ let ( alloc_timestamp , alloc_index ) = match kind {
708
708
// User allocated and stack memory should track allocation.
709
709
MemoryKind :: Machine (
710
710
MiriMemoryKind :: Rust | MiriMemoryKind :: C | MiriMemoryKind :: WinHeap
711
- ) | MemoryKind :: Stack => true ,
711
+ ) | MemoryKind :: Stack => {
712
+ let ( alloc_index, clocks) = global. current_thread_state ( ) ;
713
+ let alloc_timestamp = clocks. clock [ alloc_index] ;
714
+ ( alloc_timestamp, alloc_index)
715
+ }
712
716
// Other global memory should trace races but be allocated at the 0 timestamp.
713
717
MemoryKind :: Machine (
714
718
MiriMemoryKind :: Global | MiriMemoryKind :: Machine | MiriMemoryKind :: Env |
715
719
MiriMemoryKind :: ExternStatic | MiriMemoryKind :: Tls
716
- ) | MemoryKind :: CallerLocation | MemoryKind :: Vtable => false
717
- } ;
718
- let ( alloc_timestamp, alloc_index) = if track_alloc {
719
- let ( alloc_index, clocks) = global. current_thread_state ( ) ;
720
- let alloc_timestamp = clocks. clock [ alloc_index] ;
721
- ( alloc_timestamp, alloc_index)
722
- } else {
723
- ( 0 , VectorIdx :: MAX_INDEX )
720
+ ) | MemoryKind :: CallerLocation | MemoryKind :: Vtable => {
721
+ ( 0 , VectorIdx :: MAX_INDEX )
722
+ }
724
723
} ;
725
724
VClockAlloc {
726
725
global : Rc :: clone ( global) ,
0 commit comments