8
8
//! target x86_64
9
9
//!
10
10
//! function u0:22(i64) -> i8, i8 system_v {
11
- //! ; symbol _ZN97_$LT$example..IsNotEmpty$u20$as$u20$mini_core..FnOnce$LT$$LP$$RF$$RF$$u5b$u16$u5d$$C$$RP$$GT$$GT$9call_once17hd517c453d67c0915E
12
- //! ; instance Instance { def: Item(WithOptConstParam { did: DefId(0:42 ~ example[4e51 ]::{impl#0}::call_once), const_param_did: None } ), args: [ReErased, ReErased ] }
13
- //! ; abi FnAbi { args: [ArgAbi { layout: TyAndLayout { ty: IsNotEmpty, layout: Layout { size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Arbitrary { offsets: [], memory_index: [] }, largest_niche: None, variants: Single { index: 0 } } }, mode: Ignore }, ArgAbi { layout: TyAndLayout { ty: &&[u16], layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 } } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) }) }], ret: ArgAbi { layout: TyAndLayout { ty: (u8, u8), layout: Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, abi: ScalarPair(Initialized { value: Int(I8, false), valid_range: 0..=255 }, Initialized { value: Int(I8, false), valid_range: 0..=255 }), fields: Arbitrary { offsets: [Size(0 bytes), Size(1 bytes)], memory_index: [0, 1] }, largest_niche: None, variants: Single { index: 0 } } }, mode: Pair(ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }, ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }) }, c_variadic: false, fixed_count: 1, conv: Rust, can_unwind: false }
11
+ //! ; symbol _ZN97_$LT$example..IsNotEmpty$u20$as$u20$mini_core..FnOnce$LT$$LP$$RF$$RF$$u5b$u16$u5d$$C$$RP$$GT$$GT$9call_once17hd361e9f5c3d1c4deE
12
+ //! ; instance Instance { def: Item(DefId(0:42 ~ example[3895 ]::{impl#0}::call_once)), args: ['{erased}, '{erased} ] }
13
+ //! ; abi FnAbi { args: [ArgAbi { layout: TyAndLayout { ty: IsNotEmpty, layout: Layout { size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, backend_repr: Memory { sized: true }, fields: Arbitrary { offsets: [], memory_index: [] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 12266848898570219025 } }, mode: Ignore }, ArgAbi { layout: TyAndLayout { ty: &&[u16], layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) }) }], ret: ArgAbi { layout: TyAndLayout { ty: (u8, u8), layout: Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, backend_repr: ScalarPair(Initialized { value: Int(I8, false), valid_range: 0..=255 }, Initialized { value: Int(I8, false), valid_range: 0..=255 }), fields: Arbitrary { offsets: [Size(0 bytes), Size(1 bytes)], memory_index: [0, 1] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 71776127651151873 } }, mode: Pair(ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }, ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }) }, c_variadic: false, fixed_count: 1, conv: Rust, can_unwind: false }
14
14
//!
15
15
//! ; kind loc.idx param pass mode ty
16
- //! ; ssa _0 (u8, u8) 2b 1, 8 var=(0, 1)
16
+ //! ; ssa _0 (u8, u8) 2b 1 var=(0, 1)
17
17
//! ; ret _0 - Pair(ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }, ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }) (u8, u8)
18
18
//! ; arg _1 - Ignore IsNotEmpty
19
- //! ; arg _2.0 = v0 Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) }) && [u16]
19
+ //! ; arg _2.0 = v0 Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) }) &'{erased} &'{erased} [u16]
20
20
//!
21
- //! ; kind local ty size align (abi,pref )
22
- //! ; zst _1 IsNotEmpty 0b 1, 8 align=8 ,offset=
23
- //! ; stack _2 (&& [u16],) 8b 8, 8 storage=ss0
24
- //! ; ssa _3 &mut IsNotEmpty 8b 8, 8 var=2
21
+ //! ; kind local ty size align (abi)
22
+ //! ; zst _1 IsNotEmpty 0b 1 align=1 ,offset=
23
+ //! ; stack _2 (&'{erased} &'{erased} [u16],) 8b 8 storage=ss0
24
+ //! ; ssa _3 &'{erased} mut IsNotEmpty 8b 8 var=2
25
25
//!
26
- //! ss0 = explicit_slot 16
26
+ //! ss0 = explicit_slot 16, align = 16
27
27
//! sig0 = (i64, i64) -> i8, i8 system_v
28
- //! fn0 = colocated u0:23 sig0 ; Instance { def: Item(WithOptConstParam { did: DefId(0:46 ~ example[4e51 ]::{impl#1}::call_mut), const_param_did: None } ), args: [ReErased, ReErased ] }
28
+ //! fn0 = colocated u0:23 sig0 ; Instance { def: Item(DefId(0:46 ~ example[3895 ]::{impl#1}::call_mut)), args: ['{erased}, '{erased} ] }
29
29
//!
30
30
//! block0(v0: i64):
31
31
//! nop
32
- //! ; write_cvalue: Addr(Pointer { base: Stack(ss0), offset: Offset32(0) }, None): && [u16] <- ByVal(v0): && [u16]
32
+ //! ; write_cvalue: Addr(Pointer { base: Stack(ss0), offset: Offset32(0) }, None): &'{erased} &'{erased} [u16] <- ByVal(v0): &'{erased} &'{erased} [u16]
33
33
//! stack_store v0, ss0
34
34
//! jump block1
35
35
//!
36
36
//! block1:
37
37
//! nop
38
38
//! ; _3 = &mut _1
39
- //! v1 = iconst.i64 8
40
- //! ; write_cvalue: Var(_3, var2): &mut IsNotEmpty <- ByVal(v1): &mut IsNotEmpty
39
+ //! v1 = iconst.i64 1
40
+ //! ; write_cvalue: Var(_3, var2): &'{erased} mut IsNotEmpty <- ByVal(v1): &'{erased} mut IsNotEmpty
41
41
//! ;
42
- //! ; _0 = <IsNotEmpty as mini_core::FnMut<(&&[u16],)>>::call_mut(move _3, _2)
42
+ //! ; _0 = <IsNotEmpty as mini_core::FnMut<(&&[u16],)>>::call_mut(move _3, copy _2)
43
43
//! v2 = stack_load.i64 ss0
44
- //! v3, v4 = call fn0(v1, v2) ; v1 = 8
44
+ //! ; abi: FnAbi { args: [ArgAbi { layout: TyAndLayout { ty: &mut IsNotEmpty, layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(1 bytes)) }) }, ArgAbi { layout: TyAndLayout { ty: &&[u16], layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) }) }], ret: ArgAbi { layout: TyAndLayout { ty: (u8, u8), layout: Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, backend_repr: ScalarPair(Initialized { value: Int(I8, false), valid_range: 0..=255 }, Initialized { value: Int(I8, false), valid_range: 0..=255 }), fields: Arbitrary { offsets: [Size(0 bytes), Size(1 bytes)], memory_index: [0, 1] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 71776127651151873 } }, mode: Pair(ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }, ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }) }, c_variadic: false, fixed_count: 1, conv: Rust, can_unwind: false }
45
+ //! v3, v4 = call fn0(v1, v2) ; v1 = 1
45
46
//! v5 -> v3
46
47
//! v6 -> v4
47
48
//! ; write_cvalue: VarPair(_0, var0, var1): (u8, u8) <- ByValPair(v3, v4): (u8, u8)
@@ -73,6 +74,7 @@ pub(crate) struct CommentWriter {
73
74
enabled : bool ,
74
75
global_comments : Vec < String > ,
75
76
entity_comments : FxHashMap < AnyEntity , String > ,
77
+ inst_post_comments : FxHashMap < Inst , String > ,
76
78
}
77
79
78
80
impl CommentWriter {
@@ -95,7 +97,12 @@ impl CommentWriter {
95
97
vec ! [ ]
96
98
} ;
97
99
98
- CommentWriter { enabled, global_comments, entity_comments : FxHashMap :: default ( ) }
100
+ CommentWriter {
101
+ enabled,
102
+ global_comments,
103
+ entity_comments : FxHashMap :: default ( ) ,
104
+ inst_post_comments : FxHashMap :: default ( ) ,
105
+ }
99
106
}
100
107
}
101
108
@@ -127,6 +134,25 @@ impl CommentWriter {
127
134
}
128
135
}
129
136
}
137
+
138
+ pub ( crate ) fn add_post_comment < S : Into < String > + AsRef < str > > (
139
+ & mut self ,
140
+ entity : Inst ,
141
+ comment : S ,
142
+ ) {
143
+ debug_assert ! ( self . enabled) ;
144
+
145
+ use std:: collections:: hash_map:: Entry ;
146
+ match self . inst_post_comments . entry ( entity) {
147
+ Entry :: Occupied ( mut occ) => {
148
+ occ. get_mut ( ) . push ( '\n' ) ;
149
+ occ. get_mut ( ) . push_str ( comment. as_ref ( ) ) ;
150
+ }
151
+ Entry :: Vacant ( vac) => {
152
+ vac. insert ( comment. into ( ) ) ;
153
+ }
154
+ }
155
+ }
130
156
}
131
157
132
158
impl FuncWriter for & ' _ CommentWriter {
@@ -188,10 +214,13 @@ impl FuncWriter for &'_ CommentWriter {
188
214
inst : Inst ,
189
215
indent : usize ,
190
216
) -> fmt:: Result {
191
- PlainWriter . write_instruction ( w, func, aliases, inst, indent) ?;
192
217
if let Some ( comment) = self . entity_comments . get ( & inst. into ( ) ) {
193
218
writeln ! ( w, "; {}" , comment. replace( '\n' , "\n ; " ) ) ?;
194
219
}
220
+ PlainWriter . write_instruction ( w, func, aliases, inst, indent) ?;
221
+ if let Some ( comment) = self . inst_post_comments . get ( & inst) {
222
+ writeln ! ( w, "; {}" , comment. replace( '\n' , "\n ; " ) ) ?;
223
+ }
195
224
Ok ( ( ) )
196
225
}
197
226
}
@@ -208,6 +237,14 @@ impl FunctionCx<'_, '_, '_> {
208
237
) {
209
238
self . clif_comments . add_comment ( entity, comment) ;
210
239
}
240
+
241
+ pub ( crate ) fn add_post_comment < S : Into < String > + AsRef < str > > (
242
+ & mut self ,
243
+ entity : Inst ,
244
+ comment : S ,
245
+ ) {
246
+ self . clif_comments . add_post_comment ( entity, comment) ;
247
+ }
211
248
}
212
249
213
250
pub ( crate ) fn should_write_ir ( tcx : TyCtxt < ' _ > ) -> bool {
0 commit comments