Skip to content

Commit b93ae5b

Browse files
implement with mlir array
1 parent 7bcb98d commit b93ae5b

File tree

3 files changed

+160
-109
lines changed

3 files changed

+160
-109
lines changed

src/bin/cairo-native-run.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use cairo_native::{
1515
starknet_stub::StubSyscallHandler,
1616
};
1717
use clap::{Parser, ValueEnum};
18-
#[cfg(any(feature = "with-libfunc-profiling", feature = "with-libfunc-counter"))]
18+
#[cfg(any(feature = "with-libfunc-profiling"))]
1919
use std::collections::HashMap;
2020
use std::path::PathBuf;
2121
use tracing_subscriber::{EnvFilter, FmtSubscriber};
@@ -213,18 +213,6 @@ fn main() -> anyhow::Result<()> {
213213
.insert(0, ProfilerImpl::new());
214214
}
215215

216-
#[cfg(feature = "with-libfunc-counter")]
217-
{
218-
use cairo_native::metadata::libfunc_counter::libfunc_counter_runtime::{
219-
CounterImpl, LIBFUNC_COUNTER,
220-
};
221-
222-
LIBFUNC_COUNTER.lock().unwrap().insert(
223-
0,
224-
CounterImpl::new(sierra_program.libfunc_declarations.len()),
225-
);
226-
}
227-
228216
let gas_metadata =
229217
GasMetadata::new(&sierra_program, Some(MetadataComputationConfig::default())).unwrap();
230218

@@ -333,7 +321,6 @@ fn main() -> anyhow::Result<()> {
333321
let libfunc_counter = counters.values().next().unwrap();
334322

335323
let libfunc_counts = libfunc_counter
336-
.array_counter
337324
.iter()
338325
.enumerate()
339326
.map(|(i, count)| {
@@ -343,7 +330,6 @@ fn main() -> anyhow::Result<()> {
343330
(debug_name, *count)
344331
})
345332
.collect::<HashMap<String, u32>>();
346-
dbg!(&libfunc_counts);
347333
serde_json::to_writer_pretty(
348334
std::fs::File::create(libfunc_counter_output).unwrap(),
349335
&libfunc_counts,

src/compiler.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,10 +661,11 @@ fn compile_func(
661661
crate::metadata::libfunc_counter::libfunc_counter_runtime::count_libfunc(
662662
context,
663663
module,
664-
block,
664+
&block,
665665
location,
666666
metadata,
667667
*libfunc_idx,
668+
libfunc_indexes.len() as u32,
668669
)?;
669670
}
670671

@@ -952,6 +953,14 @@ fn compile_func(
952953
},
953954
)?;
954955

956+
#[cfg(feature = "with-libfunc-counter")]
957+
{
958+
use crate::metadata::libfunc_counter::LibfuncCounterMeta;
959+
960+
let libfunc_counter = metadata.get_mut::<LibfuncCounterMeta>().unwrap();
961+
libfunc_counter.store_array_counter(context, module, &entry_block, Location::unknown(context), libfunc_indexes.len() as u32)?;
962+
}
963+
955964
// Load arguments and jump to the entry block.
956965
{
957966
let mut arg_values = Vec::with_capacity(function.signature.param_types.len());

0 commit comments

Comments
 (0)