-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
SILOptimizerArea → compiler: SIL optimization passesArea → compiler: SIL optimization passesbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfnon-optimized onlyFlag: An issue whose reproduction requires non-optimized compilationFlag: An issue whose reproduction requires non-optimized compilation
Description
Previous ID | SR-967 |
Radar | rdar://problem/25882880 |
Original Reporter | @tjw |
Type | Bug |
Status | Resolved |
Resolution | Done |
Environment
Mac OS X 10.11.3
Xcode 7.3 beta 5
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug, NotOptimizedOnly, SILOptimizer |
Assignee | @tjw |
Priority | Medium |
md5: 0da401085b42a5ab06d529bfc8dad047
Issue Description:
With the current swift-2.2-branch build, this sample crashes:
import Foundation
extension NSDictionary {
func x() {
exit(0)
forEach { key, value in }
}
}
Note that this version does not hit the problem:
func x(values:[String:String]) {
exit(0)
value.forEach { key, value in
}
}
~/Source/Swift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift -sdk /Applications/Xcode-7.3-b5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk abort-before-foreach.swift
abort-before-foreach.swift:5:9: warning: will never be executed
forEach { key, value in }
^
abort-before-foreach.swift:4:9: note: a call to a noreturn function
exit(0)
^
SIL verification failed: Operand of dealloc_stack must be an alloc_stack: isa<AllocStackInst>(DI->getOperand())
Verifying instruction:
undef = undef<$*NSDictionary> // user: %10
-> dealloc_stack undef : $*NSDictionary // id: %10
In function:
// (extension in main):__ObjC.NSDictionary.x () -> ()
sil hidden @_TFE4mainCSo12NSDictionary1xfT_T_ : $@convention(method) (@guaranteed NSDictionary) -> () {
// %0 // user: %1
bb0(%0 : $NSDictionary):
debug_value %0 : $NSDictionary, let, name "self", argno 1 // id: %1
// function_ref exit
%2 = function_ref @exit : $@convention(c) @noreturn (Int32) -> () // user: %7
// function_ref Swift.Int32.init (_builtinIntegerLiteral : Builtin.Int2048) -> Swift.Int32
%3 = function_ref @_TFVs5Int32CfT22_builtinIntegerLiteralBi2048__S_ : $@convention(thin) (Builtin.Int2048, @thin Int32.Type) -> Int32 // user: %6
%4 = metatype $@thin Int32.Type // user: %6
%5 = integer_literal $Builtin.Int2048, 0 // user: %6
%6 = apply %3(%5, %4) : $@convention(thin) (Builtin.Int2048, @thin Int32.Type) -> Int32 // user: %7
%7 = apply %2(%6) : $@convention(c) @noreturn (Int32) -> ()
unreachable // id: %8
bb1(%9 : $()):
dealloc_stack undef : $*NSDictionary // id: %10
%11 = tuple () // user: %12
return %11 : $() // id: %12
bb2(%13 : $ErrorType):
unreachable // id: %14
}
0 swift 0x00000001080b35fe llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 46
1 swift 0x00000001080b3a39 PrintStackTraceSignalHandler(void*) + 25
2 swift 0x00000001080b02d9 llvm::sys::RunSignalHandlers() + 425
3 swift 0x00000001080b3d62 SignalHandler(int) + 354
4 libsystem_platform.dylib 0x00007fff8eb7feaa _sigtramp + 26
5 swift 0x0000000108b2bd1d cmark_strbuf__initbuf + 97548
6 swift 0x00000001080b3a5b raise + 27
7 swift 0x00000001080b3b02 abort + 18
8 swift 0x00000001030e00a7 (anonymous namespace)::SILVerifier::_require(bool, llvm::Twine const&, std::__1::function<void ()> const&) + 327
9 swift 0x00000001030ec89c (anonymous namespace)::SILVerifier::checkDeallocStackInst(swift::DeallocStackInst*) + 172
10 swift 0x00000001030e4977 (anonymous namespace)::SILVerifierBase<(anonymous namespace)::SILVerifier>::visitDeallocStackInst(swift::DeallocStackInst*) + 55
11 swift 0x00000001030e324a swift::SILVisitor<(anonymous namespace)::SILVerifier, void>::visit(swift::ValueBase*) + 378
12 swift 0x00000001030e2fd2 swift::SILVisitor<(anonymous namespace)::SILVerifier, void>::visitSILBasicBlock(swift::SILBasicBlock*) + 146
13 swift 0x00000001030e2f14 (anonymous namespace)::SILVerifier::visitSILBasicBlock(swift::SILBasicBlock*) + 932
14 swift 0x00000001030e2589 swift::SILVisitor<(anonymous namespace)::SILVerifier, void>::visitSILFunction(swift::SILFunction*) + 121
15 swift 0x00000001030e049a (anonymous namespace)::SILVerifier::visitSILFunction(swift::SILFunction*) + 1002
16 swift 0x00000001030de299 (anonymous namespace)::SILVerifier::verify() + 25
17 swift 0x00000001030de235 swift::SILFunction::verify() const + 37
18 swift 0x00000001030df542 swift::SILModule::verify() const + 386
19 swift 0x00000001037dd042 swift::SerializedSILLoader::SerializedSILLoader(swift::ASTContext&, swift::SILModule*, swift::SerializedSILLoader::Callback*) + 658
20 swift 0x00000001037dd31d swift::SerializedSILLoader::SerializedSILLoader(swift::ASTContext&, swift::SILModule*, swift::SerializedSILLoader::Callback*) + 45
21 swift 0x0000000103067544 swift::SerializedSILLoader::create(swift::ASTContext&, swift::SILModule*, swift::SerializedSILLoader::Callback*) + 84
22 swift 0x000000010305b9be swift::SILModule::getSILLoader() + 206
23 swift 0x00000001030642f3 swift::SILModule::linkFunction(swift::SILFunction*, swift::SILOptions::LinkingMode) + 67
24 swift 0x00000001034ea2b3 getCalleeFunction(swift::FullApplySite, bool&, llvm::SmallVectorImpl<swift::SILValue>&, llvm::SmallVectorImpl<swift::SILValue>&, swift::PartialApplyInst*&, swift::SILOptions::LinkingMode) + 2003
25 swift 0x00000001034e90d3 runOnFunctionRecursively(swift::SILFunction*, swift::FullApplySite, swift::SILOptions::LinkingMode, llvm::DenseSet<swift::SILFunction*, llvm::DenseMapInfo<swift::SILFunction*> >&, llvm::ImmutableSet<swift::SILFunction*, llvm::ImutContainerInfo<swift::SILFunction*> >::Factory&, llvm::ImmutableSet<swift::SILFunction*, llvm::ImutContainerInfo<swift::SILFunction*> >, swift::ClassHierarchyAnalysis*) + 1283
26 swift 0x00000001034e8a06 (anonymous namespace)::MandatoryInlining::run() + 406
27 swift 0x0000000103458278 swift::SILPassManager::runModulePass(swift::SILModuleTransform*) + 600
28 swift 0x00000001034596bd swift::SILPassManager::runOneIteration() + 1261
29 swift 0x000000010345a503 swift::SILPassManager::run() + 3555
30 swift 0x000000010346e89d swift::runSILDiagnosticPasses(swift::SILModule&) + 477
31 swift 0x0000000102c4e527 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 9607
32 swift 0x0000000102c4b6f4 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 12596
33 swift 0x0000000102c33477 main + 4231
34 libdyld.dylib 0x00007fff901fa5ad start + 1
35 libdyld.dylib 0x000000000000000c start + 1876974176
Stack dump:
0. Program arguments: /Users/bungi/Source/Swift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift -frontend -interpret abort-before-foreach.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode-7.3-b5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -color-diagnostics -module-name main
1. While running SILModuleTransform "Mandatory Inlining".
2. While verifying SIL function @_TFE4mainCSo12NSDictionary1xfT_T_ for 'x' at abort-before-foreach.swift:3:5
zsh: illegal hardware instruction ~/Source/Swift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift -sdk
Metadata
Metadata
Assignees
Labels
SILOptimizerArea → compiler: SIL optimization passesArea → compiler: SIL optimization passesbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfnon-optimized onlyFlag: An issue whose reproduction requires non-optimized compilationFlag: An issue whose reproduction requires non-optimized compilation