Deep dive into "Optimizing and Diagnostic" your Swift Code / Swiftコンパイラによる「最適化と診断」を体感する

By Aki Yuki

Elevator Pitch

Through my session, You will understand how our program is optimized by Swift Compiler. Also, you will understand the “diagnostic” of Swift Compiler which makes our code safe.

Description

Through my talk, you can understand deeply about “Optimizing and Diagnostic” of Swift Compiler phase which is a very interesting phase in compiler.

We learned many compiler knowledge in past try! Swift. For example, we learned how to read Swift Intermediate Language(SIL)and how our code is treated by Swift Compiler in Tokyo 2018(https://www.youtube.com/watch?v=sT0SNp-Tw-8).

Is it okay to only know how to read SIL? No, we can also understand “Optimizing and Diagnostic” phase in Swift Compiler.

And, we can learn following things through learning “Optimizing and Diagnosing”

  • How compiler grantees the safety of our Swift Program
  • How optimizer would destroy our Program. This would occur when we set an optimize option on the release build.

I will talk about Easy “Optimizing and Diagnostic” tutorial through my talk. You can learn how SIL is optimized by Swift compiler which from our swift code, and “Diagnostic” phase which we are touching unconsciously many times. I’ll show you the demonstration with compiler to make your understanding very deep.

Of course, I’ll show you easy tutorial of SIL and overview of Swift Compiler, so don’t be afraid to listen my talk!

本トークを通じて、Swiftコンパイラの特に面白いフェーズである、コンパイラが私達のコードに行う「最適化と診断」について深く知ることができます。

いままでのtry! Swiftではコンパイラに関するたくさんのことを学びました。例えば、Tokyo 2018では、Swift Intermediate Language(SIL)の読み歩き方を学び、私達のSwiftコードがどのようにコンパイラに取り扱われるかを学びましたね (https://www.youtube.com/watch?v=sT0SNp-Tw-8)。

では、SILを読めるようになっただけで終わりでしょうか? いいえ、SILを読めるようになった次の大きなステップとして、SwiftコンパイラがSILに対して行っている「最適化と診断」について学ぶことができます。

また、私達はSwiftコンパイラの「最適化と診断」を学ぶことを通じて、

  • 診断によって私達のプログラムはどのように安全が保証されていくのか
  • しかし、最適化は一歩間違えるとどのように危険になるか。これは例えばiPhone アプリケーションのReleaseビルドなど、最適化が様々な場面で起こりうることです。

を知ることができます。

本トークでは、Swiftコンパイラの興味深いフェーズである「最適化と診断」について、簡単に入門します。 私達のSILに変換されたSwiftのプログラムは、どのようにして最適化されているのか、そして、私達の身近にあるけど、意識してないコンパイラによる「診断」について解説します。 実際にコンパイラを使ったデモンストレーションを通じて、私達が意識しない「最適化と診断」を深く体感することができます。

もちろん、トークの冒頭では、Swiftコンパイラのオーバービューや最低限のSILの復習をしますので、お気軽に聞いてください。

Notes

本トークは英語の予定です。

また、10分に収まるべく、以下のように構成を考えています。

  • 自己紹介など (1分未満)
  • SILなどの軽い復習(2分程度)
  • 最適化について(4分程度)
  • 診断について(2分程度)
  • まとめと今後の皆さんへ学びを助けるアドバイス (1分程度)

軽めの入門なので、そこまで深すぎることは話しません。