[clang-tools-extra] [llvm] [clang] [Clang][Builtin] add __builtin_exit (PR #74803)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 20 18:46:34 PST 2024
https://github.com/W-50243 updated https://github.com/llvm/llvm-project/pull/74803
>From bcaaab24a927624669200113857fee842103d325 Mon Sep 17 00:00:00 2001
From: W-50243 <wanghao636 at huawei.com>
Date: Thu, 7 Dec 2023 19:42:29 +0800
Subject: [PATCH 1/2] [Clang][Builtin] add __builtin_exit
---
clang/include/clang/Basic/Builtins.def | 1 +
1 file changed, 1 insertion(+)
diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def
index ec39e926889b93..8b73e9c5e3594e 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -948,6 +948,7 @@ BUILTIN(__sync_fetch_and_umin, "UiUiD*Ui", "n")
BUILTIN(__sync_fetch_and_umax, "UiUiD*Ui", "n")
// Random libc builtins.
+BUILTIN(__builtin_exit, "vi", "Fnr")
BUILTIN(__builtin_abort, "v", "Fnr")
BUILTIN(__builtin_index, "c*cC*i", "Fn")
BUILTIN(__builtin_rindex, "c*cC*i", "Fn")
>From 2a664f504045b560feb9ebb6b37132ebe0a863a6 Mon Sep 17 00:00:00 2001
From: W-50243 <wanghao636 at huawei.com>
Date: Thu, 7 Dec 2023 19:42:29 +0800
Subject: [PATCH 2/2] [Clang][Builtin] add __builtin_exit
---
clang/include/clang/Basic/Builtins.def | 1 +
clang/test/CodeGen/builtin-exit-test.c | 9 +++++++++
2 files changed, 10 insertions(+)
create mode 100644 clang/test/CodeGen/builtin-exit-test.c
diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def
index ec39e926889b93..8b73e9c5e3594e 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -948,6 +948,7 @@ BUILTIN(__sync_fetch_and_umin, "UiUiD*Ui", "n")
BUILTIN(__sync_fetch_and_umax, "UiUiD*Ui", "n")
// Random libc builtins.
+BUILTIN(__builtin_exit, "vi", "Fnr")
BUILTIN(__builtin_abort, "v", "Fnr")
BUILTIN(__builtin_index, "c*cC*i", "Fn")
BUILTIN(__builtin_rindex, "c*cC*i", "Fn")
diff --git a/clang/test/CodeGen/builtin-exit-test.c b/clang/test/CodeGen/builtin-exit-test.c
new file mode 100644
index 00000000000000..1ece90de1aa4fd
--- /dev/null
+++ b/clang/test/CodeGen/builtin-exit-test.c
@@ -0,0 +1,9 @@
+//RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -Wno-strict-prototypes -triple aarch64-target-linux-gnu %s -o - | FileCheck %s
+
+//CHECK: define dso_local void @test() #0 {
+//CHECK: call void @exit(i32 noundef 1)
+//CHECK: unreachable
+
+void test(void){
+ __builtin_exit(1);
+}
More information about the cfe-commits
mailing list