diff --git a/clang/include/clang/Basic/BuiltinsARM.def b/clang/include/clang/Basic/BuiltinsARM.def --- a/clang/include/clang/Basic/BuiltinsARM.def +++ b/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.) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/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 MsvcIntId = translateArmToMsvcIntrin(BuiltinID)) diff --git a/clang/test/CodeGen/builtin-sponentry.c b/clang/test/CodeGen/builtin-sponentry.c --- 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*