[clang] [Clang][Builtin] add __builtin_exit (PR #74803)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 7 19:32:54 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (W-50243)
<details>
<summary>Changes</summary>
Add __builtin_exit in `clang/include/clang/Basic/Builtins.def` . It works perfectly on arm64be and arm64le.
---
Full diff: https://github.com/llvm/llvm-project/pull/74803.diff
2 Files Affected:
- (modified) clang/include/clang/Basic/Builtins.def (+1)
- (added) clang/test/CodeGen/builtin-exit-test.c (+9)
``````````diff
diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def
index ec39e926889b9..8b73e9c5e3594 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 0000000000000..1ece90de1aa4f
--- /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);
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/74803
More information about the cfe-commits
mailing list