88//! target x86_64
99//!
1010//! 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 }
1414//!
1515//! ; 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)
1717//! ; 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)
1818//! ; 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]
2020//!
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
2525//!
26- //! ss0 = explicit_slot 16
26+ //! ss0 = explicit_slot 16, align = 16
2727//! 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} ] }
2929//!
3030//! block0(v0: i64):
3131//! 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]
3333//! stack_store v0, ss0
3434//! jump block1
3535//!
3636//! block1:
3737//! nop
3838//! ; _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
4141//! ;
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)
4343//! 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
4546//! v5 -> v3
4647//! v6 -> v4
4748//! ; write_cvalue: VarPair(_0, var0, var1): (u8, u8) <- ByValPair(v3, v4): (u8, u8)
@@ -73,6 +74,7 @@ pub(crate) struct CommentWriter {
7374 enabled : bool ,
7475 global_comments : Vec < String > ,
7576 entity_comments : FxHashMap < AnyEntity , String > ,
77+ inst_post_comments : FxHashMap < Inst , String > ,
7678}
7779
7880impl CommentWriter {
@@ -95,7 +97,12 @@ impl CommentWriter {
9597 vec ! [ ]
9698 } ;
9799
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+ }
99106 }
100107}
101108
@@ -127,6 +134,25 @@ impl CommentWriter {
127134 }
128135 }
129136 }
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+ }
130156}
131157
132158impl FuncWriter for & ' _ CommentWriter {
@@ -188,10 +214,13 @@ impl FuncWriter for &'_ CommentWriter {
188214 inst : Inst ,
189215 indent : usize ,
190216 ) -> fmt:: Result {
191- PlainWriter . write_instruction ( w, func, aliases, inst, indent) ?;
192217 if let Some ( comment) = self . entity_comments . get ( & inst. into ( ) ) {
193218 writeln ! ( w, "; {}" , comment. replace( '\n' , "\n ; " ) ) ?;
194219 }
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+ }
195224 Ok ( ( ) )
196225 }
197226}
@@ -208,6 +237,14 @@ impl FunctionCx<'_, '_, '_> {
208237 ) {
209238 self . clif_comments . add_comment ( entity, comment) ;
210239 }
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+ }
211248}
212249
213250pub ( crate ) fn should_write_ir ( tcx : TyCtxt < ' _ > ) -> bool {
0 commit comments