Skip to content

Conversation

@TomerStarkware
Copy link
Collaborator

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@TomerStarkware TomerStarkware requested a review from orizi November 20, 2025 09:11
@TomerStarkware TomerStarkware marked this pull request as ready for review November 20, 2025 09:11
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orizi reviewed 18 of 19 files at r1, all commit messages.
Reviewable status: 18 of 19 files reviewed, 5 unresolved discussions


crates/cairo-lang-lowering/src/lower/specialized_test.rs line 68 at r1 (raw file):

                .and_then(|call| call.function.body(db).ok().flatten())
        })
        .last()

Suggestion:

        .next_back()

crates/cairo-lang-lowering/src/inline/mod.rs line 64 at r1 (raw file):

        return Ok(false);
    }
    // Breaks cycles.

doc what is the cycle break.


crates/cairo-lang-lowering/src/objects.rs line 408 at r1 (raw file):

    pub outputs: Vec<VariableId>,
    /// Is the call is to be inlined as part of the specialization wrapper function.
    pub is_specialization_inlining: bool,

improve name


crates/cairo-lang-lowering/src/optimizations/const_folding.rs line 694 at r1 (raw file):

        if scc.len() > 1 && scc.contains(&self.caller_base) {
            return None;
        }

doc what it means

Code quote:

        let scc = self.db.lowered_scc(base, DependencyType::Call, LoweringStage::Monomorphized);
        if scc.len() > 1 && scc.contains(&self.caller_base) {
            return None;
        }

crates/cairo-lang-lowering/src/lower/test_data/specialized line 833 at r1 (raw file):

error: Wrong number of arguments. Expected 2, found: 1
 --> lib.cairo:15:12
    return bar1(a - 1);

?

@TomerStarkware TomerStarkware force-pushed the tomer/11-19-allow_shallow_specialization_of_recursive_functions branch from 297571b to db714a9 Compare November 20, 2025 12:36
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orizi reviewed 9 of 22 files at r2, all commit messages.
Reviewable status: 14 of 27 files reviewed, 5 unresolved discussions (waiting on @TomerStarkware)


crates/cairo-lang-lowering/src/inline/mod.rs line 64 at r2 (raw file):

        return Ok(false);
    }
    // Prevents inlining of functions that may call themselves.

still explain why this suffices and what this does specifically.


crates/cairo-lang-lowering/src/lower/test_data/specialized line 828 at r2 (raw file):

    }
    return bar1(keep, a - 1);
}

Suggestion:

fn bar1(keep: bool, a: felt252) -> felt252 {
    if !keep || a == 0 {
        0
    } else {
        bar2(keep, a - 1)
    }
}

fn bar2(keep: bool, a: felt252) -> felt252 {
    if !keep || a == 0 {
        0
    } else {
        bar1(keep, a - 1)
    }
}

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orizi reviewed 6 of 22 files at r2.
Reviewable status: 20 of 27 files reviewed, 4 unresolved discussions (waiting on @TomerStarkware)

@TomerStarkware TomerStarkware force-pushed the tomer/11-19-allow_shallow_specialization_of_recursive_functions branch from db714a9 to ffa5a5e Compare November 20, 2025 14:28
Copy link
Collaborator Author

@TomerStarkware TomerStarkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 20 of 27 files reviewed, 4 unresolved discussions (waiting on @orizi)


crates/cairo-lang-lowering/src/inline/mod.rs line 64 at r1 (raw file):

Previously, orizi wrote…

doc what is the cycle break.

Done.


crates/cairo-lang-lowering/src/inline/mod.rs line 64 at r2 (raw file):

Previously, orizi wrote…

still explain why this suffices and what this does specifically.

Done.


crates/cairo-lang-lowering/src/lower/test_data/specialized line 833 at r1 (raw file):

Previously, orizi wrote…

?

Done.


crates/cairo-lang-lowering/src/optimizations/const_folding.rs line 694 at r1 (raw file):

Previously, orizi wrote…

doc what it means

// Avoid specializing with a function that is in the same SCC as the caller.

this is relevant for this check as well


crates/cairo-lang-lowering/src/lower/specialized_test.rs line 68 at r1 (raw file):

                .and_then(|call| call.function.body(db).ok().flatten())
        })
        .last()

Done.


crates/cairo-lang-lowering/src/lower/test_data/specialized line 828 at r2 (raw file):

    }
    return bar1(keep, a - 1);
}

Done.

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orizi reviewed 7 of 22 files at r2, 1 of 2 files at r3, all commit messages.
Reviewable status: 26 of 27 files reviewed, 2 unresolved discussions (waiting on @TomerStarkware)


crates/cairo-lang-lowering/src/inline/mod.rs line 64 at r2 (raw file):

Previously, TomerStarkware wrote…

Done.

wait - does that mean that if a loop function is called, it would be specialized, but not inlined?


crates/cairo-lang-lowering/src/lower/test_data/specialized line 813 at r3 (raw file):


//! > module_code
fn bar1(keep: bool, a: felt252) -> felt252 {

dup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants