Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
Options.JMCInstrument = CodeGenOpts.JMCInstrument;
Options.XCOFFReadOnlyPointers = CodeGenOpts.XCOFFReadOnlyPointers;

if (LangOpts.Kernel)
Options.TrapUnreachable = true;

switch (CodeGenOpts.getSwiftAsyncFramePointer()) {
case CodeGenOptions::SwiftAsyncFramePointerKind::Auto:
Options.SwiftAsyncFramePointer =
Expand Down
24 changes: 24 additions & 0 deletions clang/test/CodeGen/MSKernel/noreturn.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// REQUIRES: x86-registered-target
// RUN: %clang_cc1 -fms-kernel -fms-extensions -triple x86_64-windows-msvc -O2 -S %s -o - | FileCheck %s

// CHECK-LABEL: my_noreturn_func:
// CHECK: callq bugcheck
// CHECK-NEXT: ud2

// CHECK-LABEL: my_noreturn_func2:
// CHECK: movl $0, (%rax)
// CHECK-NEXT: ud2

void bugcheck(int code);

extern long volatile *gtrap;

__declspec(noreturn) void my_noreturn_func(void) {
bugcheck(0x42);
}


__declspec(noreturn) void my_noreturn_func2(void) {
*gtrap = 0;
}