[PATCH] D61592: [AArch64] Add __builtin_sponentry, for calling setjmp in MinGW
Martin Storsjö via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 6 06:17:57 PDT 2019
mstorsjo created this revision.
mstorsjo added reviewers: rnk, efriedma, mgrang, ssijaric.
Herald added subscribers: kristina, kristof.beyls, javed.absar.
Herald added a project: clang.
In MinGW, setjmp isn't expanded as a builtin in the compiler (like it is for MSVC), but manually hooked up as calls to the right underlying functions in headers. Using the actual CRT's real setjmp/longjmp functions requires this intrinsic. (Currently this is worked around by using MinGW specific reimplementations of setjmp/longjmp on aarch64.)
Repository:
rC Clang
https://reviews.llvm.org/D61592
Files:
include/clang/Basic/BuiltinsAArch64.def
lib/CodeGen/CGBuiltin.cpp
test/CodeGen/builtin-sponentry.c
Index: test/CodeGen/builtin-sponentry.c
===================================================================
--- /dev/null
+++ test/CodeGen/builtin-sponentry.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple aarch64-windows-gnu -Oz -emit-llvm %s -o - | FileCheck %s
+
+void *test_sponentry() {
+ return __builtin_sponentry();
+}
+// CHECK-LABEL: define dso_local i8* @test_sponentry()
+// CHECK: = tail call i8* @llvm.sponentry()
+// CHECK: ret i8*
Index: lib/CodeGen/CGBuiltin.cpp
===================================================================
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7233,6 +7233,11 @@
return Builder.CreateCall(F);
}
+ if (BuiltinID == AArch64::BI__builtin_sponentry) {
+ llvm::Function *F = CGM.getIntrinsic(Intrinsic::sponentry);
+ return Builder.CreateCall(F);
+ }
+
// Find out if any arguments are required to be integer constant
// expressions.
unsigned ICEArguments = 0;
Index: include/clang/Basic/BuiltinsAArch64.def
===================================================================
--- include/clang/Basic/BuiltinsAArch64.def
+++ include/clang/Basic/BuiltinsAArch64.def
@@ -86,6 +86,9 @@
LANGBUILTIN(__sev, "v", "", ALL_MS_LANGUAGES)
LANGBUILTIN(__sevl, "v", "", ALL_MS_LANGUAGES)
+// Misc
+BUILTIN(__builtin_sponentry, "v*", "c")
+
TARGET_HEADER_BUILTIN(_BitScanForward, "UcUNi*UNi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
TARGET_HEADER_BUILTIN(_BitScanReverse, "UcUNi*UNi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
TARGET_HEADER_BUILTIN(_BitScanForward64, "UcUNi*ULLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61592.198258.patch
Type: text/x-patch
Size: 1608 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190506/7b4e0b2e/attachment.bin>
More information about the cfe-commits
mailing list