@@ -21,6 +21,7 @@ use crate::context::r#loop::Loop;
21
21
use crate :: context:: IContext ;
22
22
use crate :: debug_config:: DebugConfig ;
23
23
use crate :: evm:: build:: Build as EVMBuild ;
24
+ use crate :: evm:: profiler:: Profiler ;
24
25
use crate :: evm:: warning:: Warning ;
25
26
use crate :: optimizer:: settings:: Settings as OptimizerSettings ;
26
27
use crate :: optimizer:: Optimizer ;
@@ -121,10 +122,17 @@ impl<'ctx> Context<'ctx> {
121
122
output_assembly : bool ,
122
123
output_bytecode : bool ,
123
124
is_size_fallback : bool ,
125
+ profiler : & mut Profiler ,
124
126
) -> anyhow:: Result < EVMBuild > {
125
127
let module_clone = self . module . clone ( ) ;
126
128
let contract_path = self . module . get_name ( ) . to_str ( ) . expect ( "Always valid" ) ;
127
129
130
+ let run_init_verify = profiler. start_evm_translation_unit (
131
+ contract_path,
132
+ self . code_segment ,
133
+ "InitVerify" ,
134
+ self . optimizer . settings ( ) ,
135
+ ) ;
128
136
let target_machine = TargetMachine :: new (
129
137
era_compiler_common:: Target :: EVM ,
130
138
self . optimizer . settings ( ) ,
@@ -158,7 +166,14 @@ impl<'ctx> Context<'ctx> {
158
166
self . code_segment,
159
167
)
160
168
} ) ?;
169
+ run_init_verify. borrow_mut ( ) . finish ( ) ;
161
170
171
+ let run_optimize_verify = profiler. start_evm_translation_unit (
172
+ contract_path,
173
+ self . code_segment ,
174
+ "OptimizeVerify" ,
175
+ self . optimizer . settings ( ) ,
176
+ ) ;
162
177
self . optimizer
163
178
. run ( & target_machine, self . module ( ) )
164
179
. map_err ( |error| anyhow:: anyhow!( "{} code optimizing: {error}" , self . code_segment) ) ?;
@@ -176,8 +191,15 @@ impl<'ctx> Context<'ctx> {
176
191
self . code_segment,
177
192
)
178
193
} ) ?;
194
+ run_optimize_verify. borrow_mut ( ) . finish ( ) ;
179
195
180
196
let assembly_buffer = if output_assembly || self . debug_config . is_some ( ) {
197
+ let run_emit_llvm_assembly = profiler. start_evm_translation_unit (
198
+ contract_path,
199
+ self . code_segment ,
200
+ "EmitLLVMAssembly" ,
201
+ self . optimizer . settings ( ) ,
202
+ ) ;
181
203
let assembly_buffer = target_machine
182
204
. write_to_memory_buffer ( self . module ( ) , inkwell:: targets:: FileType :: Assembly )
183
205
. map_err ( |error| anyhow:: anyhow!( "assembly emitting: {error}" ) ) ?;
@@ -193,6 +215,7 @@ impl<'ctx> Context<'ctx> {
193
215
) ?;
194
216
}
195
217
218
+ run_emit_llvm_assembly. borrow_mut ( ) . finish ( ) ;
196
219
Some ( assembly_buffer)
197
220
} else {
198
221
None
@@ -201,11 +224,18 @@ impl<'ctx> Context<'ctx> {
201
224
. map ( |assembly_buffer| String :: from_utf8_lossy ( assembly_buffer. as_slice ( ) ) . to_string ( ) ) ;
202
225
203
226
if output_bytecode {
227
+ let run_emit_bytecode = profiler. start_evm_translation_unit (
228
+ contract_path,
229
+ self . code_segment ,
230
+ "EmitBytecode" ,
231
+ self . optimizer . settings ( ) ,
232
+ ) ;
204
233
let bytecode_buffer = target_machine
205
234
. write_to_memory_buffer ( self . module ( ) , inkwell:: targets:: FileType :: Object )
206
235
. map_err ( |error| {
207
236
anyhow:: anyhow!( "{} bytecode emitting: {error}" , self . code_segment)
208
237
} ) ?;
238
+ run_emit_bytecode. borrow_mut ( ) . finish ( ) ;
209
239
210
240
let immutables = match self . code_segment {
211
241
era_compiler_common:: CodeSegment :: Deploy => None ,
@@ -242,7 +272,7 @@ impl<'ctx> Context<'ctx> {
242
272
for function in self . module . get_functions ( ) {
243
273
Function :: set_size_attributes ( self . llvm , function) ;
244
274
}
245
- return self . build ( output_assembly, output_bytecode, true ) ;
275
+ return self . build ( output_assembly, output_bytecode, true , profiler ) ;
246
276
} else {
247
277
warnings. push ( match self . code_segment {
248
278
era_compiler_common:: CodeSegment :: Deploy => Warning :: DeployCodeSize {
0 commit comments