[PATCH] D126764: [clang] [ARM] Add __builtin_sponentry like on aarch64

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 1 03:03:57 PDT 2022


mstorsjo created this revision.
mstorsjo added reviewers: efriedma, zzheng.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: clang.

This is used for calling the SEH aware setjmp on MinGW.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126764

Files:
  clang/include/clang/Basic/BuiltinsARM.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtin-sponentry.c


Index: clang/test/CodeGen/builtin-sponentry.c
===================================================================
--- clang/test/CodeGen/builtin-sponentry.c
+++ clang/test/CodeGen/builtin-sponentry.c
@@ -1,8 +1,9 @@
 // RUN: %clang_cc1 -no-opaque-pointers -triple aarch64-windows-gnu -Oz -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -triple thumbv7-windows-gnu -Oz -emit-llvm %s -o - | FileCheck %s
 
 void *test_sponentry(void) {
   return __builtin_sponentry();
 }
-// CHECK-LABEL: define dso_local i8* @test_sponentry()
+// CHECK-LABEL: define dso_local {{(arm_aapcs_vfpcc )?}}i8* @test_sponentry()
 // CHECK: = tail call i8* @llvm.sponentry.p0i8()
 // CHECK: ret i8*
Index: clang/lib/CodeGen/CGBuiltin.cpp
===================================================================
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -7783,6 +7783,11 @@
                                       AccessKind);
   }
 
+  if (BuiltinID == ARM::BI__builtin_sponentry) {
+    llvm::Function *F = CGM.getIntrinsic(Intrinsic::sponentry, AllocaInt8PtrTy);
+    return Builder.CreateCall(F);
+  }
+
   // Handle MSVC intrinsics before argument evaluation to prevent double
   // evaluation.
   if (Optional<MSVCIntrin> MsvcIntId = translateArmToMsvcIntrin(BuiltinID))
Index: clang/include/clang/Basic/BuiltinsARM.def
===================================================================
--- clang/include/clang/Basic/BuiltinsARM.def
+++ clang/include/clang/Basic/BuiltinsARM.def
@@ -197,6 +197,9 @@
 BUILTIN(__builtin_arm_wsr64, "vcC*LLUi", "nc")
 BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
 
+// Misc
+BUILTIN(__builtin_sponentry, "v*", "c")
+
 // Builtins for implementing ACLE MVE intrinsics. (Unlike NEON, these
 // don't need to live in a separate BuiltinsMVE.def, because they
 // aren't included from both here and BuiltinsAArch64.def.)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126764.433338.patch
Type: text/x-patch
Size: 1880 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220601/1830ae4f/attachment-0001.bin>


More information about the cfe-commits mailing list