diff options
author | Martin Storsjo <martin@martin.st> | 2019-05-06 21:19:07 +0000 |
---|---|---|
committer | Martin Storsjo <martin@martin.st> | 2019-05-06 21:19:07 +0000 |
commit | b91f1c80f6212af9c62b235a4f07dab5067add4b (patch) | |
tree | 584bcffbc004c15e3a88e7ab290a3cabebaa4680 | |
parent | d653c3f8e2168eb215fc2f74728b664947f7a478 (diff) |
[AArch64] Add __builtin_sponentry, for calling setjmp in MinGW
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.)
Differential Revision: https://reviews.llvm.org/D61592
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360082 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/BuiltinsAArch64.def | 3 | ||||
-rw-r--r-- | lib/CodeGen/CGBuiltin.cpp | 5 | ||||
-rw-r--r-- | test/CodeGen/builtin-sponentry.c | 8 |
3 files changed, 16 insertions, 0 deletions
diff --git a/include/clang/Basic/BuiltinsAArch64.def b/include/clang/Basic/BuiltinsAArch64.def index 76f6948065..5ba03da4a7 100644 --- a/include/clang/Basic/BuiltinsAArch64.def +++ b/include/clang/Basic/BuiltinsAArch64.def @@ -86,6 +86,9 @@ LANGBUILTIN(__wfi, "v", "", ALL_MS_LANGUAGES) 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, "") diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 14b8d0b18d..048103275d 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -7233,6 +7233,11 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, 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; diff --git a/test/CodeGen/builtin-sponentry.c b/test/CodeGen/builtin-sponentry.c new file mode 100644 index 0000000000..0a85089106 --- /dev/null +++ b/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* |