@@ -704,23 +704,22 @@ pub struct VClockAlloc {
704704impl VClockAlloc {
705705 /// Create a new data-race detector for newly allocated memory.
706706 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 {
708708 // User allocated and stack memory should track allocation.
709709 MemoryKind :: Machine (
710710 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+ }
712716 // Other global memory should trace races but be allocated at the 0 timestamp.
713717 MemoryKind :: Machine (
714718 MiriMemoryKind :: Global | MiriMemoryKind :: Machine | MiriMemoryKind :: Env |
715719 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+ }
724723 } ;
725724 VClockAlloc {
726725 global : Rc :: clone ( global) ,
0 commit comments