@@ -30,8 +30,7 @@ fn mutexattr_get_kind<'mir, 'tcx: 'mir>(
30
30
// Ensure that the following read at an offset to the attr pointer is within bounds
31
31
assert_ptr_target_min_size ( ecx, attr_op, 4 ) ?;
32
32
let attr_place = ecx. deref_operand ( attr_op) ?;
33
- let i32_layout = ecx. layout_of ( ecx. tcx . types . i32 ) ?;
34
- let kind_place = attr_place. offset ( Size :: ZERO , MemPlaceMeta :: None , i32_layout, ecx) ?;
33
+ let kind_place = attr_place. offset ( Size :: ZERO , MemPlaceMeta :: None , ecx. i32_layout ( ) ?, ecx) ?;
35
34
ecx. read_scalar ( kind_place. into ( ) )
36
35
}
37
36
@@ -43,8 +42,7 @@ fn mutexattr_set_kind<'mir, 'tcx: 'mir>(
43
42
// Ensure that the following write at an offset to the attr pointer is within bounds
44
43
assert_ptr_target_min_size ( ecx, attr_op, 4 ) ?;
45
44
let attr_place = ecx. deref_operand ( attr_op) ?;
46
- let i32_layout = ecx. layout_of ( ecx. tcx . types . i32 ) ?;
47
- let kind_place = attr_place. offset ( Size :: ZERO , MemPlaceMeta :: None , i32_layout, ecx) ?;
45
+ let kind_place = attr_place. offset ( Size :: ZERO , MemPlaceMeta :: None , ecx. i32_layout ( ) ?, ecx) ?;
48
46
ecx. write_scalar ( kind. into ( ) , kind_place. into ( ) )
49
47
}
50
48
@@ -64,9 +62,8 @@ fn mutex_get_locked_count<'mir, 'tcx: 'mir>(
64
62
// Ensure that the following read at an offset to the mutex pointer is within bounds
65
63
assert_ptr_target_min_size ( ecx, mutex_op, 20 ) ?;
66
64
let mutex_place = ecx. deref_operand ( mutex_op) ?;
67
- let u32_layout = ecx. layout_of ( ecx. tcx . types . u32 ) ?;
68
65
let locked_count_place =
69
- mutex_place. offset ( Size :: from_bytes ( 4 ) , MemPlaceMeta :: None , u32_layout, ecx) ?;
66
+ mutex_place. offset ( Size :: from_bytes ( 4 ) , MemPlaceMeta :: None , ecx . u32_layout ( ) ? , ecx) ?;
70
67
ecx. read_scalar ( locked_count_place. into ( ) )
71
68
}
72
69
@@ -78,9 +75,8 @@ fn mutex_set_locked_count<'mir, 'tcx: 'mir>(
78
75
// Ensure that the following write at an offset to the mutex pointer is within bounds
79
76
assert_ptr_target_min_size ( ecx, mutex_op, 20 ) ?;
80
77
let mutex_place = ecx. deref_operand ( mutex_op) ?;
81
- let u32_layout = ecx. layout_of ( ecx. tcx . types . u32 ) ?;
82
78
let locked_count_place =
83
- mutex_place. offset ( Size :: from_bytes ( 4 ) , MemPlaceMeta :: None , u32_layout, ecx) ?;
79
+ mutex_place. offset ( Size :: from_bytes ( 4 ) , MemPlaceMeta :: None , ecx . u32_layout ( ) ? , ecx) ?;
84
80
ecx. write_scalar ( locked_count. into ( ) , locked_count_place. into ( ) )
85
81
}
86
82
@@ -91,10 +87,13 @@ fn mutex_get_kind<'mir, 'tcx: 'mir>(
91
87
// Ensure that the following read at an offset to the mutex pointer is within bounds
92
88
assert_ptr_target_min_size ( ecx, mutex_op, 20 ) ?;
93
89
let mutex_place = ecx. deref_operand ( mutex_op) ?;
94
- let i32_layout = ecx. layout_of ( ecx. tcx . types . i32 ) ?;
95
90
let kind_offset = if ecx. pointer_size ( ) . bytes ( ) == 8 { 16 } else { 12 } ;
96
- let kind_place =
97
- mutex_place. offset ( Size :: from_bytes ( kind_offset) , MemPlaceMeta :: None , i32_layout, ecx) ?;
91
+ let kind_place = mutex_place. offset (
92
+ Size :: from_bytes ( kind_offset) ,
93
+ MemPlaceMeta :: None ,
94
+ ecx. i32_layout ( ) ?,
95
+ ecx,
96
+ ) ?;
98
97
ecx. read_scalar ( kind_place. into ( ) )
99
98
}
100
99
@@ -106,10 +105,13 @@ fn mutex_set_kind<'mir, 'tcx: 'mir>(
106
105
// Ensure that the following write at an offset to the mutex pointer is within bounds
107
106
assert_ptr_target_min_size ( ecx, mutex_op, 20 ) ?;
108
107
let mutex_place = ecx. deref_operand ( mutex_op) ?;
109
- let i32_layout = ecx. layout_of ( ecx. tcx . types . i32 ) ?;
110
108
let kind_offset = if ecx. pointer_size ( ) . bytes ( ) == 8 { 16 } else { 12 } ;
111
- let kind_place =
112
- mutex_place. offset ( Size :: from_bytes ( kind_offset) , MemPlaceMeta :: None , i32_layout, ecx) ?;
109
+ let kind_place = mutex_place. offset (
110
+ Size :: from_bytes ( kind_offset) ,
111
+ MemPlaceMeta :: None ,
112
+ ecx. i32_layout ( ) ?,
113
+ ecx,
114
+ ) ?;
113
115
ecx. write_scalar ( kind. into ( ) , kind_place. into ( ) )
114
116
}
115
117
@@ -128,9 +130,8 @@ fn rwlock_get_readers<'mir, 'tcx: 'mir>(
128
130
// Ensure that the following read at an offset to the rwlock pointer is within bounds
129
131
assert_ptr_target_min_size ( ecx, rwlock_op, 12 ) ?;
130
132
let rwlock_place = ecx. deref_operand ( rwlock_op) ?;
131
- let u32_layout = ecx. layout_of ( ecx. tcx . types . u32 ) ?;
132
133
let readers_place =
133
- rwlock_place. offset ( Size :: from_bytes ( 4 ) , MemPlaceMeta :: None , u32_layout, ecx) ?;
134
+ rwlock_place. offset ( Size :: from_bytes ( 4 ) , MemPlaceMeta :: None , ecx . u32_layout ( ) ? , ecx) ?;
134
135
ecx. read_scalar ( readers_place. into ( ) )
135
136
}
136
137
@@ -142,9 +143,8 @@ fn rwlock_set_readers<'mir, 'tcx: 'mir>(
142
143
// Ensure that the following write at an offset to the rwlock pointer is within bounds
143
144
assert_ptr_target_min_size ( ecx, rwlock_op, 12 ) ?;
144
145
let rwlock_place = ecx. deref_operand ( rwlock_op) ?;
145
- let u32_layout = ecx. layout_of ( ecx. tcx . types . u32 ) ?;
146
146
let readers_place =
147
- rwlock_place. offset ( Size :: from_bytes ( 4 ) , MemPlaceMeta :: None , u32_layout, ecx) ?;
147
+ rwlock_place. offset ( Size :: from_bytes ( 4 ) , MemPlaceMeta :: None , ecx . u32_layout ( ) ? , ecx) ?;
148
148
ecx. write_scalar ( readers. into ( ) , readers_place. into ( ) )
149
149
}
150
150
@@ -155,9 +155,8 @@ fn rwlock_get_writers<'mir, 'tcx: 'mir>(
155
155
// Ensure that the following read at an offset to the rwlock pointer is within bounds
156
156
assert_ptr_target_min_size ( ecx, rwlock_op, 12 ) ?;
157
157
let rwlock_place = ecx. deref_operand ( rwlock_op) ?;
158
- let u32_layout = ecx. layout_of ( ecx. tcx . types . u32 ) ?;
159
158
let writers_place =
160
- rwlock_place. offset ( Size :: from_bytes ( 8 ) , MemPlaceMeta :: None , u32_layout, ecx) ?;
159
+ rwlock_place. offset ( Size :: from_bytes ( 8 ) , MemPlaceMeta :: None , ecx . u32_layout ( ) ? , ecx) ?;
161
160
ecx. read_scalar ( writers_place. into ( ) )
162
161
}
163
162
@@ -169,9 +168,8 @@ fn rwlock_set_writers<'mir, 'tcx: 'mir>(
169
168
// Ensure that the following write at an offset to the rwlock pointer is within bounds
170
169
assert_ptr_target_min_size ( ecx, rwlock_op, 12 ) ?;
171
170
let rwlock_place = ecx. deref_operand ( rwlock_op) ?;
172
- let u32_layout = ecx. layout_of ( ecx. tcx . types . u32 ) ?;
173
171
let writers_place =
174
- rwlock_place. offset ( Size :: from_bytes ( 8 ) , MemPlaceMeta :: None , u32_layout, ecx) ?;
172
+ rwlock_place. offset ( Size :: from_bytes ( 8 ) , MemPlaceMeta :: None , ecx . u32_layout ( ) ? , ecx) ?;
175
173
ecx. write_scalar ( writers. into ( ) , writers_place. into ( ) )
176
174
}
177
175
0 commit comments