Skip to content

[ast]/[silgen] If a case stmt is a fallthrough source, tail allocate a pointer in the case stmt to the fallthrough case. #23284

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

Merged

Conversation

gottesmm
Copy link
Contributor

The second commit uses this in SILGenPattern in a trivial way to show that everything works.

@gottesmm gottesmm requested review from akyrtzi and nathawes March 14, 2019 01:14
@gottesmm
Copy link
Contributor Author

I am mainly asking for review of the first commit.

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@@ -920,6 +922,45 @@ class CaseLabelItem {
}
};

/// FallthroughStmt - The keyword "fallthrough".
class FallthroughStmt : public Stmt {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are no changes here to FallthroughStmt. I just ran into issues with my uses for it in CaseStmt and then discovered that I couldn't just use a forward declaration of it = /.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

*So I moved it above CaseStmt.

@gottesmm
Copy link
Contributor Author

Since I based the logic on identifying fallthroughs on the logic in SILGenPattern, the actual output from SILGenPattern should be not changed at all so test updates were not needed.

private llvm::TrailingObjects<CaseStmt, CaseLabelItem> {
class CaseStmt final
: public Stmt,
private llvm::TrailingObjects<CaseStmt, FallthroughStmt *,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided to store the entire FallthroughStmt * rather than a pointer to the CaseStmt* returned from FallthroughStmt::getFallthroughDest(). This seems more flexible. That being said, I did not want to add it to the API surface, so I did not expose it directly.

@@ -943,24 +986,47 @@ class CaseStmt final : public Stmt,

llvm::PointerIntPair<Stmt *, 1, bool> BodyAndHasBoundDecls;

/// Set to true if we have a fallthrough.
///
/// TODO: Once we have CaseBodyVarDecls, use the bit in BodyAndHasBoundDecls
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be clear here: HasBoundDecls is true iff we have CaseBodyVarDecls to my commit adding those will fix that. I just did not want to create a field called BodyAndHasBoundDeclsAndHasFallthrough...

@gottesmm
Copy link
Contributor Author

One last comment. I checked for other places that were using CaseStmt::create. This is the only call site AFAIKT that can have a fallthrough. This can be seen since FallthroughStmt are only created in the parser, never in sema.

Copy link
Contributor

@akyrtzi akyrtzi left a comment

Choose a reason for hiding this comment

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

Looks good apart from some nitpick and clarifying question.

…est() instead of computing this itself.

rdar://47467128
@gottesmm gottesmm force-pushed the pr-0b4de614fe103f8e5a161be5219ba2cb7148aa25 branch from 91c34cc to 7b27b4b Compare March 14, 2019 18:25
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

1 similar comment
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

Copy link
Contributor

@akyrtzi akyrtzi left a comment

Choose a reason for hiding this comment

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

LGTM!

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test and merge

2 similar comments
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test and merge

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test and merge

@gottesmm
Copy link
Contributor Author

I killed the two non smoke test and merge jobs that I triggered.

@gottesmm
Copy link
Contributor Author

The linux case failed b/c of 12:19:01 SwiftXCTestFunctionalTests :: Asynchronous/Expectations/main.swift

I need to get around to fixing that.

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test linux platform

@gottesmm gottesmm merged commit 1e0414d into swiftlang:master Mar 14, 2019
@gottesmm gottesmm deleted the pr-0b4de614fe103f8e5a161be5219ba2cb7148aa25 branch March 14, 2019 21:03
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.

2 participants