Compilation fails with valid code when "Fastest -O" optimizations are set [Swift]
| Originator: | tadeas | ||
| Number: | rdar://21603216 | Date Originated: | 30-Jun-2015 02:18 AM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | |
| Classification: | Reproducible: | Always |
Summary:
In the attached Swift source file you can see the least needed to reproduce the bug. The compilation succeeds when optimizations are turned off in Debug configuration, but once you want to run Release configuration, you get very vague error from xcode: "Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1".
I stared digging deeper into the issue and found out that the real error was:
PHINode should have one entry for each predecessor of its parent basic block!
%11 = phi i64 [ %43, %33 ], [ 0, %29 ], !dbg !747
LLVM ERROR: Broken function found, compilation aborted!
The compilation stops failing when you do one of two things. Either you can make the property in the Foo protocol read-only (by setting it only to { get } ) or not doing the property override in the ChildFoo class.
Steps to Reproduce:
1. Create new Single-View iOS project
2. Put the contents of the attached file into any source file that will be compiled in the project (you can even place it into AppDelegate.swift)
3. In the project build configuration, make sure you change Swift optimization level to "Fastest -O"
4. Run the build
Expected Results:
Expected result is a successful build.
Actual Results:
As already stated in the description, it fails with message: "Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1" and when I run the command manually, the problem was:
PHINode should have one entry for each predecessor of its parent basic block!
%11 = phi i64 [ %43, %33 ], [ 0, %29 ], !dbg !747
LLVM ERROR: Broken function found, compilation aborted!
Version:
Xcode 6.3.2 (6D2105)
OS X Yosemite 10.10.3
Swift 1.2
Notes:
Configuration:
This occurs only when the Swift compiler's optimization level is set to "Fastest -O" and I'm using Swift 1.2
Attachments:
'crash.swift' was successfully uploaded.
# openradar only: the contents of crash.swift:
protocol Foo {
var bar: String { get set }
}
class BaseFoo: Foo {
var bar: String = "hello"
}
class ChildFoo: BaseFoo {
private var _bar: String = "world"
override var bar: String {
get {
return _bar
}
set {
_bar = newValue
}
}
}
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!