swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.67k stars 10.38k forks source link

[SR-6369] [sil-opt] Unreachable in late inliner: "not valid in canonical SIL" #48919

Open 0acf245c-f0fa-406f-afb9-4746d10f0359 opened 7 years ago

0acf245c-f0fa-406f-afb9-4746d10f0359 commented 7 years ago
Previous ID SR-6369
Radar None
Original Reporter @dcci
Type Bug

Attachment: Download

Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: d1f8766b4fa92857e7e8d574dc410123

Issue Description:

stack trace:

not valid in canonical sil                                                                                                                                                    [8/899]
UNREACHABLE executed at /home/davide/work/swift/swift/lib/SILOptimizer/Utils/SILInliner.cpp:464!
#​0 0x00000000037aec3f llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/davide/work/swift/llvm/lib/Support/Unix/Signals.inc:398:13
#&#8203;1 0x00000000037aef46 bool __gnu_cxx::operator!=<std::pair<void (*)(void*), void*>*, std::vector<std::pair<void (*)(void*), void*>, std::allocator<std::pair<void (*)(void*), void*>
> > >(__gnu_cxx::__normal_iterator<std::pair<void (*)(void*), void*>*, std::vector<std::pair<void (*)(void*), void*>, std::allocator<std::pair<void (*)(void*), void*> > > > const&, __gnu_cxx::__normal_iterator<std::pair<void (*)(void*), void*>*, std::vector<std::pair<void (*)(void*), void*>, std::allocator<std::pair<void (*)(void*), void*> > > > const&) /usr/l
ib/gcc/x86_64-redhat-linux/6.3.1/../../../../include/c++/6.3.1/bits/stl_iterator.h:880:27
#&#8203;2 0x00000000037aef46 llvm::sys::RunSignalHandlers() /home/davide/work/swift/llvm/lib/Support/Signals.cpp:49:0
#&#8203;3 0x00000000037aef46 SignalHandler(int) /home/davide/work/swift/llvm/lib/Support/Unix/Signals.inc:242:0
#&#8203;4 0x00007f725bc4ec30 __restore_rt (/lib64/libpthread.so.0+0x10c30)
#&#8203;5 0x00007f725a3ad765 __GI_raise (/lib64/libc.so.6+0x34765)
#&#8203;6 0x00007f725a3af36a __GI_abort (/lib64/libc.so.6+0x3636a)
#&#8203;7 0x0000000003753d59 (./sil-opt+0x3753d59)
#&#8203;8 0x0000000000999cea swift::instructionInlineCost(swift::SILInstruction&) /home/davide/work/swift/swift/lib/SILOptimizer/Utils/SILInliner.cpp:469:3
#&#8203;9 0x00000000007efd88 void ShortestPathAnalysis::analyze<(anonymous namespace)::SILPerformanceInliner::collectAppliesToInline(swift::SILFunction*, llvm::SmallVectorImpl<swift::FullA
pplySite>&)::$_4>(swift::ColdBlockInfo&, (anonymous namespace)::SILPerformanceInliner::collectAppliesToInline(swift::SILFunction*, llvm::SmallVectorImpl<swift::FullApplySite>&)::$_4
) /home/davide/work/swift/swift/include/swift/SILOptimizer/Utils/PerformanceInlinerUtils.h:405:28
#&#8203;10 0x00000000007efd88 (anonymous namespace)::SILPerformanceInliner::collectAppliesToInline(swift::SILFunction*, llvm::SmallVectorImpl<swift::FullApplySite>&) /home/davide/work/swif
t/swift/lib/SILOptimizer/Transforms/PerformanceInliner.cpp:696:0
#&#8203;11 0x00000000007ef125 llvm::SmallVectorBase::empty() const /home/davide/work/swift/llvm/include/llvm/ADT/SmallVector.h:60:46
#&#8203;12 0x00000000007ef125 (anonymous namespace)::SILPerformanceInliner::inlineCallsIntoFunction(swift::SILFunction*) /home/davide/work/swift/swift/lib/SILOptimizer/Transforms/Performan
ceInliner.cpp:812:0
#&#8203;13 0x00000000007ef125 (anonymous namespace)::SILPerformanceInlinerPass::run() /home/davide/work/swift/swift/lib/SILOptimizer/Transforms/PerformanceInliner.cpp:919:0
#&#8203;14 0x00000000006fbbf8 llvm::SmallVectorTemplateCommon<swift::SILAnalysis*, void>::begin() /home/davide/work/swift/llvm/include/llvm/ADT/SmallVector.h:115:45
#&#8203;15 0x00000000006fbbf8 swift::SILPassManager::analysesUnlocked() /home/davide/work/swift/swift/lib/SILOptimizer/PassManager/PassManager.cpp:264:0
#&#8203;16 0x00000000006fbbf8 swift::SILPassManager::runPassOnFunction(swift::SILFunctionTransform*, swift::SILFunction*) /home/davide/work/swift/swift/lib/SILOptimizer/PassManager/PassMan
ager.cpp:341:0
#&#8203;17 0x00000000006fca0b std::vector<swift::SILPassManager::WorklistEntry, std::allocator<swift::SILPassManager::WorklistEntry> >::operator[](unsigned long) /usr/lib/gcc/x86_64-redhat
-linux/6.3.1/../../../../include/c++/6.3.1/bits/stl_vector.h:781:32
#&#8203;18 0x00000000006fca0b swift::SILPassManager::runFunctionPasses(llvm::ArrayRef<swift::SILFunctionTransform*>) /home/davide/work/swift/swift/lib/SILOptimizer/PassManager/PassManager.
cpp:426:0
#&#8203;19 0x00000000006fddac llvm::SmallVectorImpl<swift::SILFunctionTransform*>::clear() /home/davide/work/swift/llvm/include/llvm/ADT/SmallVector.h:349:24
#&#8203;20 0x00000000006fddac swift::SILPassManager::runOneIteration() /home/davide/work/swift/swift/lib/SILOptimizer/PassManager/PassManager.cpp:525:0
#&#8203;21 0x00000000004689f8 __gnu_cxx::__normal_iterator<swift::SILPassPipeline const*, std::vector<swift::SILPassPipeline, std::allocator<swift::SILPassPipeline> > >::operator++() /usr/
lib/gcc/x86_64-redhat-linux/6.3.1/../../../../include/c++/6.3.1/bits/stl_iterator.h:799:2
#&#8203;22 0x00000000004689f8 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) /home/davide/work/swift/swift/include/swift/SILOptimizer/PassManager/PassMan
ager.h:247:0
#&#8203;23 0x0000000000465a9e std::_Vector_base<swift::SILPassPipeline, std::allocator<swift::SILPassPipeline> >::~_Vector_base() /usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../include
/c++/6.3.1/bits/stl_vector.h:160:37
#&#8203;24 0x0000000000465a9e std::vector<swift::SILPassPipeline, std::allocator<swift::SILPassPipeline> >::~vector() /usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../include/c++/6.3.1/b
its/stl_vector.h:427:0
#&#8203;25 0x0000000000465a9e swift::SILPassPipelinePlan::~SILPassPipelinePlan() /home/davide/work/swift/swift/include/swift/SILOptimizer/PassManager/PassPipeline.h:49:0
#&#8203;26 0x0000000000465a9e runCommandLineSelectedPasses(swift::SILModule*, swift::irgen::IRGenModule*) /home/davide/work/swift/swift/tools/sil-opt/SILOpt.cpp:242:0
#&#8203;27 0x0000000000465a9e main /home/davide/work/swift/swift/tools/sil-opt/SILOpt.cpp:442:0

cmdline (the test is in tree):

$ ./sil-opt /home/davide/work/swift/swift/test/SILOptimizer//allocbox_to_stack.sil -o /dev/null -assume-parsing-unqualified-ownership-sil -verify -late-inline

swift revision:

commit 4a92c603f1f8ba53834f6ea8aa3b45eb8e92ed28
Merge: 40b443e 5e36991
Author: adrian-prantl <adrian-prantl@users.noreply.github.com>
Date:   Sun Nov 12 11:11:44 2017 -0800

    Merge pull request #&#8203;12889 from adrian-prantl/35430708

    Debug Info / SILGen: fix the source location of variable assignments
0acf245c-f0fa-406f-afb9-4746d10f0359 commented 7 years ago

Reduced cmdline

~/work/swift/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/bin/sil-opt $1 -o /dev/null -assume-parsing-unqualified-ownership-sil -late-inline [^blah.sil] 

& test attached