-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[embedded] Remove unspecialized functions before running IRGen #68781
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
Conversation
@swift-ci please test |
@swift-ci please test Linux platform |
@swift-ci please test Windows platform |
ef4310e
to
b049319
Compare
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically LGTM.
I have some comments/questions
@@ -526,6 +546,8 @@ class DeadFunctionAndGlobalElimination { | |||
|
|||
// Check vtable methods. | |||
for (auto &vTable : Module->getVTables()) { | |||
LLVM_DEBUG(llvm::dbgs() << " processing vtable " | |||
<< vTable->getClass()->getName() << '\n'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to be very careful with class methods. I'm not sure if DFE will now remove generic (non-final) vtable methods - which are not allowed in embedded swift. If we don't diagnose this earlier, calling such a method will result in a runtime error instead of a compiler error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, and this PR is not changing anything around classes and DFE on them (it doesn't happen). I just added this log to get some more visibility into what is considered to be anchors when debugging.
@@ -891,6 +891,13 @@ SILPassPipelinePlan::getIRGenPreparePassPipeline(const SILOptions &Options) { | |||
// boundaries as required by the ABI. | |||
P.addLoadableByAddress(); | |||
|
|||
if (Options.EmbeddedSwift) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this pass run really needed? There is already a LateDeadFunctionElimination earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's only present in the -O pipeline. But I think we need it to happen in -Onone too, and the embedded/debuginfo.swift shows a problem specifically about -Onone + -g. Any better suggestions for how to ensure this pass runs in all pipelines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could add it to getOnonePassPipeline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved.
@swift-ci please test |
@swift-ci please test |
@swift-ci please test Windows platform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
This fixes a problem when emitting debuginfo in IRGen where we might have an "inlined at" debuginfo reference to an unspecialized function, which in turn causes it to get lazily emitted, which crashes in embedded Swift. See the attached testcase for a small reproducer.