Uploaded image for project: 'Swift'
  1. Swift
  2. SR-11010

Swift 5.1 infinite compile with optimizations

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler
    • Environment:

      Xcode 11 beta 2 11M337n
      macOS 10.14.5 18F203

      Description

      With Swift 5.1 and this code:

      import UIKit
      
      class SomeView: UIView {
          override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
              var view = super.hitTest(.zero, with: nil)
              while !(view is UIView) {
                  view = view?.superview
              }
      
              return nil
          }
      }
      

      If you build it with:

      DEVELOPER_DIR=/Applications/Xcode-beta.app xcrun --sdk iphonesimulator swiftc -O -target x86_64-apple-ios13.0-simulator foo.swift
      

      The build never completes (I waited 70 minutes on my non-reduced case before cancelling). If you remove the `-O` it completes as expected. During this time swift also consumes 100% CPU. Here's a sample during this time:

      Call graph:
          2840 Thread_8326431   DispatchQueue_1: com.apple.main-thread  (serial)
            2840 start  (in libdyld.dylib) + 1  [0x7fff78a1d3d5]
              2840 main  (in swift) + 1219  [0x10b0cb333]
                2840 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*)  (in swift) + 6868  [0x10b13c0a4]
                  2840 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*)  (in swift) + 34357  [0x10b147fd5]
                    2840 swift::CompilerInstance::performSILProcessing(swift::SILModule*, swift::UnifiedStatsReporter*)  (in swift) + 6379  [0x10b4496cb]
                      2840 swift::SILPassManager::execute()  (in swift) + 4599  [0x10b7e62f7]
                        2840 (anonymous namespace)::JumpThreadSimplifyCFGPass::run()  (in swift) + 885  [0x10b8d1e95]
                          2840 (anonymous namespace)::SimplifyCFG::run()  (in swift) + 119  [0x10b8a1987]
                            2840 (anonymous namespace)::SimplifyCFG::simplifyBlocks()  (in swift) + 28081,28141,...  [0x10b8af0b1,0x10b8af0ed,...]
      
      Total number in stack (recursive counted multiple, when >=5):
      
      Sort by top of stack, same collapsed (when >= 5):
              (anonymous namespace)::SimplifyCFG::simplifyBlocks()  (in swift)        2840
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            keith Keith Smiley
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: