Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWT module clone - set original functions to be optimised and cloned as unoptimised. #222

Merged

Conversation

Pavel-Durov
Copy link

Interpreter starts always in optimised (non-tracing) mode, therefore the original module should be set as optimised.

@Pavel-Durov Pavel-Durov changed the title SWT clone module - set original functions to be optimised and cloned as unoptimised. SWT module clone - set original functions to be optimised and cloned as unoptimised. Jan 9, 2025
@Pavel-Durov
Copy link
Author

Pavel-Durov commented Jan 9, 2025

For some reason yk simple_peeling.c test is failing but I don't see how its related to these changes 🤔
That's the only test that is failing, with error:

Pattern (error at line 6):
   ...
   |...
   |header_start ...
   |...
>> |header_end [%{{0}}, %{{1}}, %{{2}}, %{{3}}, %{{4}}]
   |...
   |body_start [%{{19}}, %{{20}}, %{{21}}, %{{22}}, %{{23}}]
   |...
   ...

Text (error at line 17):
   ...
   |    %2: ptr = param Register(15, 8, [])
   |    %3: ptr = param Register(12, 8, [])
   |    header_start [%0, %1, %2, %3]
>> |    %5: ptr = lookup_global @stderr
   |    %6: ptr = load %5
   |    %7: i32 = load %3
   |    %8: ptr = lookup_global @.str
   ...

---- lang_tests::simple_peeling.c stdout ----

@ltratt
Copy link

ltratt commented Jan 9, 2025

That test is affected by a recent change to ykllvm -- but that change hasn't (yet) successfully merged into yk.

@ptersilie
Copy link

Does this change which functions we inline during tracing? I remember there was some discussion around this. For example, we know we need to trace the unopt functions, which then get inlined. But what happens when we outline a function. I think at the moment we just emit calls to the unopt functions from the trace. We might later want to rewrite these calls to actually call the opt functions. Though I think that's an optimisation. But it's worth thinking about.

@Pavel-Durov
Copy link
Author

Pavel-Durov commented Jan 10, 2025

Does this change which functions we inline during tracing?

I don't think it changes anything in terms of tracing inlining. In this PR both versions will have the tracing calls so
essentially both versions will be unoptimised until the control point transition is implemented.

I remember there was some discussion around this. For example, we know we need to trace the unopt functions, which then get inlined. But what happens when we outline a function. I think at the moment we just emit calls to the unopt functions from the trace. We might later want to rewrite these calls to actually call the opt functions. Though I think that's an optimisation. But it's worth thinking about.

I don't remember what we said about funcion inclining tbh (and I can't find anything in my notes about it 😶 ).
But we can call opt functions instead of unopt when outlining, don't see an issue with that.

if (F.getName().startswith(YK_CLONE_PREFIX)) {
continue;
}
// FIXME: Once control point transition is implemented,

Choose a reason for hiding this comment

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

Why are we adding them to both at the moment?

Copy link
Author

@Pavel-Durov Pavel-Durov Jan 10, 2025

Choose a reason for hiding this comment

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

To remove tracing calls from the original functions (opt functions in this PR) we will need first to implement the control point transition between opt and unopt versions.
Right now the functions are cloned but they are not used at all, yk swt executes only the original functions.

Choose a reason for hiding this comment

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

I see. Okay, let's remove the commented code though. We can add it back later.

Copy link
Author

Choose a reason for hiding this comment

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

removed 👉 24eceaa

@ptersilie
Copy link

Please squash,

Interpreter starts always in optimised (non-tracing) mode, therefore
the original module should be set as optimised.
@Pavel-Durov Pavel-Durov force-pushed the set-set-original-module-as-optimised branch from 24eceaa to 9504103 Compare January 10, 2025 16:17
@Pavel-Durov
Copy link
Author

Squashed 👉 9504103

@ptersilie ptersilie added this pull request to the merge queue Jan 13, 2025
Merged via the queue into ykjit:main with commit 7386572 Jan 13, 2025
2 checks passed
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.

3 participants