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-6846] Swift 4.1 compiler crash with optimization #49395

Closed
swift-ci opened this issue Jan 26, 2018 · 4 comments
Closed

[SR-6846] Swift 4.1 compiler crash with optimization #49395

swift-ci opened this issue Jan 26, 2018 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software regression swift 4.1

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-6846
Radar rdar://problem/36911790
Original Reporter Masaki Fuke (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode 9.3 beta 1

Additional Detail from JIRA
Votes 2
Component/s Compiler
Labels Bug, 4.1Regression, CompilerCrash
Assignee @vedantk
Priority Medium

md5: 873214da148fa7b83fe538e0de08098c

is blocked by:

  • SR-6800 Swift 4.1 regression: compiler crash with optimizations (instrprof failed to lower an increment UNREACHABLE executed)

Issue Description:

Swift 4.1 compiler will crash the project using Carthage module.

  1. set optimization for speed [-O]

  2. import Carthage module

  3. Subclassing Carthage module's class

  4. override the method and change return type to internal type.

I add sample project.

That includes APIKit added by Carthage and MySession class in AppDelegate.swift is problematic class.

<unknown>:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log
0  swift                    0x0000000109b6078a PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x0000000109b5fb46 SignalHandler(int) + 966
2  libsystem_platform.dylib 0x00007fff7f4f3f5a _sigtramp + 26
3  libsystem_platform.dylib 0x00007ffee9ab3538 _sigtramp + 1784411640
4  swift                    0x0000000106f14203 swift::PrintingDiagnosticConsumer::handleDiagnostic(swift::SourceManager&, swift::SourceLoc, swift::DiagnosticKind, llvm::StringRef, llvm::ArrayRef<swift::DiagnosticArgument>, swift::DiagnosticInfo const&) + 1203
5  swift                    0x00000001061be25f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*)::$0::invoke(void*, std::1::basic_string<char, std::1::char_traits<char>, std::_1::allocator<char> > const&, bool) + 351
6  swift                    0x0000000109b17dc8 llvm::report_fatal_error(llvm::Twine const&, bool) + 280
7  swift                    0x0000000109b17e5f llvm::report_fatal_error(std::_1::basic_string<char, std::1::char_traits<char>, std::_1::allocator<char> > const&, bool) + 31
8  swift                    0x0000000107e82160 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) + 21120
9  swift                    0x00000001076fa025 (anonymous namespace)::X86DAGToDAGISel::Select(llvm::SDNode*) + 3045
10 swift                    0x0000000107e77ae9 llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 3161
11 swift                    0x0000000107e74afe llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 17358
12 swift                    0x0000000107e6f81d llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 2461
13 swift                    0x00000001076f7fa4 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 20
14 swift                    0x0000000108284436 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 134
15 swift                    0x0000000109a87d11 llvm::FPPassManager::runOnFunction(llvm::Function&) + 449
16 swift                    0x0000000109a87953 llvm::FPPassManager::runOnModule(llvm::Module&) + 67
17 swift                    0x0000000109a91328 llvm::legacy::PassManager::run(llvm::Module&) + 1112
18 swift                    0x00000001063676b1 swift::performLLVM(swift::IRGenOptions&, swift::DiagnosticEngine*, llvm::sys::SmartMutex<false>, llvm::GlobalVariable, llvm::Module*, llvm::TargetMachine*, swift::version::Version const&, llvm::StringRef, swift::UnifiedStatsReporter*) + 7409
19 swift                    0x00000001061c919d performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 44685
20 swift                    0x00000001061bc894 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7908
21 swift                    0x00000001061712c5 main + 18917
22 libdyld.dylib            0x00007fff7f272115 start + 1
23 libdyld.dylib            0x0000000000000041 start + 2161696557
@belkadan
Copy link
Contributor

aschwaighofer@apple.com (JIRA User), is this one of the ones you've seen recently?

@swift-ci create

@aschwaighofer
Copy link
Member

No (maybe we inherited an LLVM bug)

@vedantk
Copy link
Member

vedantk commented Jan 26, 2018

The APIKit swiftmodule contains serialized SIL with instrprof_increment intrinsics in it. I suppose with swift 4.1, we eagerly store more SIL in modules when optimizing.

I think this deserves a two-part fix:

  1. Always run the instrprof lowering pass in Swift, regardless of whether -profile-generate was used, and
  2. Tune the lowering pass in LLVM to exit early when there are no relevant intrinsics, to avoid a compile time impact

@vedantk
Copy link
Member

vedantk commented Jan 27, 2018

Jordan suggested a simpler approach where we don't lower the SIL builtin when the primary module has profiling disabled. I went with that (#14206

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 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 crash Bug: A crash, i.e., an abnormal termination of software regression swift 4.1
Projects
None yet
Development

No branches or pull requests

5 participants