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-5968] Build never ends if SWIFT_OPTIMIZATION_LEVEL is -O or -Owholemodule in Xcode 9 #48527

Closed
swift-ci opened this issue Sep 22, 2017 · 7 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself optimized only Flag: An issue whose reproduction requires optimized compilation

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-5968
Radar rdar://problem/34602036
Original Reporter kishikawakatsumi (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode Version 9.0 (9A235)
macOS Sierra 10.12.6

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, OptimizedOnly
Assignee @swiftix
Priority Medium

md5: cdbcbf00f74d364d30452e27a6b6a353

Issue Description:

Summary

Build never ends if SWIFT_OPTIMIZATION_LEVEL is `-O` or `-Owholemodule` in Xcode 9.
CPU usage of swift process reaches 100%.

Steps to Reproduce:

  1. Create a new Swift project.

  2. Set `SWIFT_OPTIMIZATION_LEVEL = -O` in build setting or select Release build configuration in schema

  3. Add a new file and paste the following code

  4. Build

public class A {
    public class func f() {
        B.f()
    }
}

class B {
    private class C {
        var this: C? = nil

        lazy var number: Int = {
            var local: C? = self
            let count = 0
            while let temp = local?.this {
                local = temp
            }
            return count
        }()

        func f() -> C {
            if number == 0 {
                return self
            }
            print(number)
            return self
        }
    }

    class func f() {
        let _ = C().f()
    }
}

Expected Results:

Build finishes

Actual Results:

Build never ends, swift process CPU usage reaches 100%

@belkadan
Copy link
Contributor

Whatever it is, it seems to be fixed on master. shajrawi (JIRA User), does this look familiar?

@swift-ci
Copy link
Collaborator Author

Comment by Joe Shajrawi (JIRA)

I am not familiar with it but it is not fixed on master. at least on my machine. Clean top of tree build spends forever in SimplifyCFG.

@swift-ci
Copy link
Collaborator Author

Comment by Joe Shajrawi (JIRA)

@swift-ci create

@swift-ci
Copy link
Collaborator Author

Comment by Joe Shajrawi (JIRA)

Instruments:

2.83 min 100.0% 0 s swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*)
2.83 min 100.0% 0 s performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*)
2.83 min 100.0% 0 s swift::runSILOptimizationPasses(swift::SILModule&)
2.83 min 100.0% 0 s swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&)
2.83 min 100.0% 0 s swift::SILPassManager::runOneIteration()
2.83 min 100.0% 0 s swift::SILPassManager::runFunctionPasses(llvm::ArrayRef<swift::SILFunctionTransform*>)
2.83 min 100.0% 0 s swift::SILPassManager::runPassOnFunction(swift::SILFunctionTransform*, swift::SILFunction*)
2.83 min 100.0% 0 s (anonymous namespace)::SimplifyCFGPass::run()
2.83 min 100.0% 0 s (anonymous namespace)::SimplifyCFG::run()
2.83 min 100.0% 0 s (anonymous namespace)::SimplifyCFG::simplifyBlocks()
2.83 min 100.0% 0 s (anonymous namespace)::SimplifyCFG::simplifyArgs(swift::SILBasicBlock*)
2.83 min 100.0% 0 s removeArgument(swift::SILBasicBlock*, unsigned int)
2.75 min 97.1% 34.86 s swift::SILBuilder::addOpenedArchetypeOperands(swift::SILInstruction*)

@swiftix
Copy link
Mannequin

swiftix mannequin commented Sep 25, 2017

I fixed it on swift/master in commit 7f4c4f7

@swiftix
Copy link
Mannequin

swiftix mannequin commented Sep 25, 2017

Fix committed on swift/master and swift-4.0-branch.

@sjavora
Copy link
Contributor

sjavora commented Oct 13, 2017

@swiftix Sorry if this is not the way/place to ask this, but when is this fix going to propagate into Xcode? Our project is currently experiencing this and Xcode 9.1 beta 2 seems to behave in the same way as Xcode 9.0.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself optimized only Flag: An issue whose reproduction requires optimized compilation
Projects
None yet
Development

No branches or pull requests

3 participants