Skip to content
Closed
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
6 changes: 4 additions & 2 deletions clang/include/clang/Basic/Builtins.td
Original file line number Diff line number Diff line change
Expand Up @@ -2660,9 +2660,10 @@ def Calloc : LibBuiltin<"stdlib.h"> {
}

def Exit : LibBuiltin<"stdlib.h"> {
let Spellings = ["exit", "_Exit"];
let Spellings = ["exit"];
let Attributes = [NoReturn];
let Prototype = "void(int)";
let AddBuiltinPrefixedAlias = 1;
}

def Malloc : LibBuiltin<"stdlib.h"> {
Expand Down Expand Up @@ -3266,9 +3267,10 @@ def StrnCaseCmp : GNULibBuiltin<"strings.h"> {
}

def GNU_Exit : GNULibBuiltin<"unistd.h"> {
let Spellings = ["_exit"];
let Spellings = ["_exit", "_Exit"];
let Attributes = [NoReturn];
let Prototype = "void(int)";
let AddBuiltinPrefixedAlias = 1;
}

def VFork : LibBuiltin<"unistd.h"> {
Expand Down
21 changes: 21 additions & 0 deletions clang/test/CodeGen/attributes.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,27 @@ void t24(f_t f1) {
(*p)();
}

// CHECK:define{{.*}} void @t25() [[NUW]] {
// CHECK: call void @exit(i32 noundef 1)
// CHECK-NEXT: unreachable
void t25(void) {
__builtin_exit(1);
}

// CHECK:define{{.*}} void @t26() [[NUW]] {
// CHECK: call void @_exit(i32 noundef 2)
// CHECK-NEXT: unreachable
void t26(void) {
__builtin__exit(2);
}

// CHECK:define{{.*}} void @t27() [[NUW]] {
// CHECK: call void @_Exit(i32 noundef 3)
// CHECK-NEXT: unreachable
void t27(void) {
__builtin__Exit(3);
}

// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} }
// CHECK: attributes [[NR]] = { noinline noreturn nounwind{{.*}} }
// CHECK: attributes [[COLDDEF]] = { cold {{.*}}}
Expand Down