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

[SR-340] Refactor SILParser::parseSILInstruction #42962

Open
gottesmm opened this issue Dec 22, 2015 · 7 comments
Open

[SR-340] Refactor SILParser::parseSILInstruction #42962

gottesmm opened this issue Dec 22, 2015 · 7 comments
Assignees
Labels
compiler The Swift compiler itself good first issue Good for newcomers nfc Flag: No Functional Change SILParser Area → compiler: The SIL parser task

Comments

@gottesmm
Copy link
Contributor

Previous ID SR-340
Radar None
Original Reporter @gottesmm
Type Bug
Status In Progress
Resolution
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, StarterBug
Assignee d066z (JIRA)
Priority Medium

md5: ee6df5ef735c9655c56ca6ce06200e7e

Issue Description:

parseSILInstruction is horrible and makes me cry every time I see it. It is a method that is ~1900 lines with a huge switch in it. We should refactor it into a visitor structure. In fact it is large enough that we should consider moving it into its own file if it is possible.

@belkadan
Copy link
Contributor

Resetting assignee for all Starter Bugs not modified since 2018.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added SILParser Area → compiler: The SIL parser task and removed bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. labels Mar 10, 2023
@Kyle-Ye
Copy link
Contributor

Kyle-Ye commented May 16, 2023

After this commit, parseSILInstruction was optimized into 76 lines of code. Maybe we should close this issue.

@Kyle-Ye Kyle-Ye closed this as completed May 16, 2023
@AnthonyLatsis AnthonyLatsis added the nfc Flag: No Functional Change label May 16, 2023
@AnthonyLatsis
Copy link
Collaborator

This is still relevant because no visitor-oriented refactoring took place. The referenced commit simply decouples the problematic code into a dedicated function.

@AnthonyLatsis AnthonyLatsis reopened this May 16, 2023
@oozoofrog
Copy link
Contributor

oozoofrog commented Jul 13, 2024

@AnthonyLatsis I found that these functions are called within parseTopLevelSIL in ParseDecl.cpp. :)
I've been tracing the call hierarchy of parseSpecificSILInstruction through parseSILInstruction and up to parseDeclSIL and parseSILGlobal, but I'm unable to find where parseDeclSIL and parseSILGlobal is actually being used in the codebase. Could help me understand where and how parseDeclSIL and parseSILGlobal is invoked in the Swift compiler? Are there any entry points or higher-level parsing functions that call parseDeclSIL? I'd appreciate any insights into how this SIL parsing chain is initiated and utilized in the broader context of the compiler.

@AnthonyLatsis
Copy link
Collaborator

@oozoofrog Are you working on this? Let me know if you want to be assigned.

@oozoofrog
Copy link
Contributor

oozoofrog commented Jul 16, 2024

@oozoofrog Are you working on this? Let me know if you want to be assigned.

Yes I'm working on this, can I get assigned?

@oozoofrog
Copy link
Contributor

oozoofrog commented Jul 16, 2024

@AnthonyLatsis Thanks for the assign on this issue.
I've begun working on separating the numerous switch cases in the 'parseSpecificSILInstruction' function into a separate visitor. I've focused on this function as I believe it's the most problematic. I'd appreciate your thoughts on whether this approach is sufficient or if there are any shortcomings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler itself good first issue Good for newcomers nfc Flag: No Functional Change SILParser Area → compiler: The SIL parser task
Projects
None yet
Development

No branches or pull requests

5 participants