[clang] f730749 - [clang] [ARM] Add __builtin_sponentry like on aarch64

Martin Storsjö via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 2 02:31:24 PDT 2022


Author: Martin Storsjö
Date: 2022-06-02T12:29:59+03:00
New Revision: f730749e8584fe7ea3927d0359f20d167d281e80

URL: https://github.com/llvm/llvm-project/commit/f730749e8584fe7ea3927d0359f20d167d281e80
DIFF: https://github.com/llvm/llvm-project/commit/f730749e8584fe7ea3927d0359f20d167d281e80.diff

LOG: [clang] [ARM] Add __builtin_sponentry like on aarch64

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

Differential Revision: https://reviews.llvm.org/D126764

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/BuiltinsARM.def b/clang/include/clang/Basic/BuiltinsARM.def
index be20c24aa28ae..0cea0a9051e5b 100644
--- a/clang/include/clang/Basic/BuiltinsARM.def
+++ b/clang/include/clang/Basic/BuiltinsARM.def
@@ -197,6 +197,9 @@ BUILTIN(__builtin_arm_wsr, "vcC*Ui", "nc")
 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.)

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index bdc638299c4bd..1c10d32de5fe9 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -7783,6 +7783,11 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
                                       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))

diff  --git a/clang/test/CodeGen/builtin-sponentry.c b/clang/test/CodeGen/builtin-sponentry.c
index ce389f6aee374..7487f602f36b8 100644
--- a/clang/test/CodeGen/builtin-sponentry.c
+++ b/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*


        


More information about the cfe-commits mailing list