Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/cairo-lang-lowering/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ salsa.workspace = true
serde = { workspace = true, default-features = true }
starknet-types-core.workspace = true
thiserror.workspace = true
tracing = { workspace = true, features = ["log"] }


[dev-dependencies]
cairo-lang-plugins = { path = "../cairo-lang-plugins" }
Expand Down
20 changes: 20 additions & 0 deletions crates/cairo-lang-lowering/src/optimizations/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/// Macro for debug logging with "optimization" target.
#[allow(unused)]
macro_rules! debug {
($($arg:tt)*) => {
tracing::debug!(target: "optimization", $($arg)*)
};
}
#[allow(unused_imports)]
pub(crate) use debug;

/// Macro for trace logging with "optimization" target.
#[allow(unused)]
macro_rules! trace {
($($arg:tt)*) => {
tracing::trace!(target: "optimization", $($arg)*)
};
}
#[allow(unused_imports)]
pub(crate) use trace;

pub mod branch_inversion;
pub mod cancel_ops;
pub mod config;
Expand Down
2 changes: 2 additions & 0 deletions crates/cairo-lang-lowering/src/optimizations/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ impl<'db> OptimizationPhase<'db> {
function: ConcreteFunctionWithBodyId<'db>,
lowered: &mut Lowered<'db>,
) -> Maybe<()> {
debug!("Applying optimization: {self:?}");

match self {
OptimizationPhase::ApplyInlining { enable_const_folding } => {
apply_inlining(db, function, lowered, enable_const_folding)?
Expand Down
21 changes: 13 additions & 8 deletions crates/cairo-lang-test-utils/src/parse_test_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@ pub fn dump_to_test_file(
for (test_name, test) in tests {
let mut tag_strings = vec![TAG_PREFIX.to_string() + &test_name];
for (tag, content) in test.attributes {
tag_strings.push(
TAG_PREFIX.to_string()
+ &tag
+ if content.is_empty() { "" } else { "\n" }
+ &content,
);
if tag != "test_name" {
tag_strings.push(
TAG_PREFIX.to_string()
+ &tag
+ if content.is_empty() { "" } else { "\n" }
+ &content,
);
}
}
test_strings.push(tag_strings.join("\n\n"));
}
Expand Down Expand Up @@ -139,8 +141,11 @@ impl TestBuilder {
}

fn set_test_name(&mut self, line: String, line_num: usize) {
self.current_test_name = Some(line);
self.current_test = Some(Test { attributes: OrderedHashMap::default(), line_num });
self.current_test_name = Some(line.clone());
self.current_test = Some(Test {
attributes: OrderedHashMap::from([("test_name".to_string(), line)]),
line_num,
});
}

fn add_content_line(&mut self, line: String) {
Expand Down