Skip to content

Commit 225c406

Browse files
author
git apple-llvm automerger
committed
Merge commit '19ebfa6d0b9b' from llvm.org/main into next
2 parents a74f815 + 19ebfa6 commit 225c406

File tree

6 files changed

+79
-24
lines changed

6 files changed

+79
-24
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,10 @@ struct RuntimeLibcallsInfo {
233233
}
234234

235235
/// Generated by tablegen.
236-
void setTargetRuntimeLibcallSets(const Triple &TT, FloatABI::ABIType FloatABI,
237-
EABI ABIType, StringRef ABIName);
236+
void setTargetRuntimeLibcallSets(const Triple &TT,
237+
ExceptionHandling ExceptionModel,
238+
FloatABI::ABIType FloatABI, EABI ABIType,
239+
StringRef ABIName);
238240

239241
/// Set default libcall names. If a target wants to opt-out of a libcall it
240242
/// should be placed here.

llvm/include/llvm/IR/RuntimeLibcalls.td

Lines changed: 69 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ def hasSinCos : RuntimeLibcallPredicate<"hasSinCos(TT)">;
3939
// FIXME: Way to combine predicates
4040
def hasSinCos_f32_f64 : RuntimeLibcallPredicate<"hasSinCos_f32_f64(TT)">;
4141

42+
def ExceptionModelIsNotNone : RuntimeLibcallPredicate<
43+
[{ExceptionModel != ExceptionHandling::None}]
44+
>;
45+
46+
def ExceptionModelIsSjLj : RuntimeLibcallPredicate<
47+
[{ExceptionModel == ExceptionHandling::SjLj}]
48+
>;
49+
4250
//--------------------------------------------------------------------
4351
// Declare all kinds of used libcalls
4452
//--------------------------------------------------------------------
@@ -707,10 +715,6 @@ foreach MemSize = [ 1, 2, 4, 8, 16 ] in {
707715
!cast<RuntimeLibcall>("MEMSET_ELEMENT_UNORDERED_ATOMIC_"#MemSize)>;
708716
}
709717

710-
// Exception handling
711-
def _Unwind_Resume : RuntimeLibcallImpl<UNWIND_RESUME>;
712-
def __cxa_end_cleanup : RuntimeLibcallImpl<CXA_END_CLEANUP>;
713-
714718
// Atomic '__sync_*' libcalls.
715719
foreach lc = LibCalls__sync in {
716720
def __#!tolower(!cast<string>(lc)) : RuntimeLibcallImpl<lc>;
@@ -1014,9 +1018,20 @@ defm sincos : LibmLongDoubleLibCall;
10141018

10151019
def bzero : RuntimeLibcallImpl<BZERO>;
10161020
def __bzero : RuntimeLibcallImpl<BZERO>;
1017-
def _Unwind_SjLj_Resume : RuntimeLibcallImpl<UNWIND_RESUME>;
1018-
def _Unwind_SjLj_Register : RuntimeLibcallImpl<UNWIND_REGISTER>;
1019-
def _Unwind_SjLj_Unregister : RuntimeLibcallImpl<UNWIND_UNREGISTER>;
1021+
1022+
// Exception handling
1023+
defset list<RuntimeLibcallImpl> DefaultExceptionHandlingLibcalls = {
1024+
def _Unwind_Resume : RuntimeLibcallImpl<UNWIND_RESUME>;
1025+
def __cxa_end_cleanup : RuntimeLibcallImpl<CXA_END_CLEANUP>;
1026+
}
1027+
1028+
defset list<RuntimeLibcallImpl> SjLjExceptionHandlingLibcalls = {
1029+
def _Unwind_SjLj_Resume : RuntimeLibcallImpl<UNWIND_RESUME>;
1030+
def _Unwind_SjLj_Register : RuntimeLibcallImpl<UNWIND_REGISTER>;
1031+
def _Unwind_SjLj_Unregister : RuntimeLibcallImpl<UNWIND_UNREGISTER>;
1032+
}
1033+
1034+
// Only used on wasm?
10201035
def _Unwind_CallPersonality : RuntimeLibcallImpl<UNWIND_CALL_PERSONALITY>;
10211036

10221037
// Used on OpenBSD
@@ -1092,6 +1107,13 @@ defset list<RuntimeLibcallImpl> LibmF128FiniteLibcalls = {
10921107
// Common Libcall Sets
10931108
//===----------------------------------------------------------------------===//
10941109

1110+
defvar ExceptionModelCalls = (add
1111+
LibcallImpls<(add DefaultExceptionHandlingLibcalls),
1112+
ExceptionModelIsNotNone>,
1113+
LibcallImpls<(add SjLjExceptionHandlingLibcalls),
1114+
ExceptionModelIsSjLj>
1115+
);
1116+
10951117
// FIXME: Should move to explicit opt-in to different sets of libcalls
10961118
// instead of trying to remove from a default set. We have
10971119
// unreasonable defaults like reporting f80 calls on most targets when
@@ -1112,19 +1134,25 @@ defvar DefaultRuntimeLibcallImpls_f128 =
11121134
!filter(entry, AllDefaultRuntimeLibcallImpls,
11131135
!match(!cast<string>(entry.Provides), "_F128"));
11141136

1115-
defvar DefaultRuntimeLibcallImpls =
1137+
// FIXME: Ideally we would just use dags everywhere, but for the
1138+
// arm64ec case we need iterable lists so we can add the # prefix
1139+
defvar DefaultRuntimeLibcallImplsBaseList =
11161140
!listremove(
11171141
!listremove(
11181142
!listremove(AllDefaultRuntimeLibcallImpls, Int128RTLibcalls),
11191143
DefaultRuntimeLibcallImpls_f80),
11201144
DefaultRuntimeLibcallImpls_ppcf128);
11211145

1146+
defvar DefaultRuntimeLibcallImpls =
1147+
(add DefaultRuntimeLibcallImplsBaseList,
1148+
ExceptionModelCalls);
1149+
11221150
/// Default set of libcall impls for 32-bit architectures.
1123-
defvar DefaultLibcallImpls32 = DefaultRuntimeLibcallImpls;
1151+
defvar DefaultLibcallImpls32 = (add DefaultRuntimeLibcallImpls);
11241152

11251153
/// Default set of libcall impls for 64-bit architectures.
1126-
defvar DefaultLibcallImpls64 = !listconcat(DefaultRuntimeLibcallImpls,
1127-
Int128RTLibcalls);
1154+
defvar DefaultLibcallImpls64 = (add DefaultRuntimeLibcallImpls,
1155+
Int128RTLibcalls);
11281156

11291157
defvar DarwinSinCosStret = LibcallImpls<(add __sincosf_stret, __sincos_stret),
11301158
darwinHasSinCosStret>;
@@ -1160,7 +1188,12 @@ defvar WindowsExclusions = !listconcat(WindowsMathRemovals, MostPowI);
11601188

11611189
// Targets which support windows should start with these as a base and
11621190
// add in calls for other OSes
1163-
defvar WinDefaultLibcallImpls = !listremove(DefaultRuntimeLibcallImpls, WindowsExclusions);
1191+
defvar WinDefaultLibcallImplsBaseList =
1192+
!listremove(DefaultRuntimeLibcallImplsBaseList,
1193+
WindowsExclusions);
1194+
1195+
defvar WinDefaultLibcallImpls = (add WinDefaultLibcallImplsBaseList,
1196+
ExceptionModelCalls);
11641197

11651198
defvar LibmHasFrexpF32 = LibcallImpls<(add frexpf), isNotOSWindowsOrIsCygwinMinGW>;
11661199
defvar LibmHasLdexpF32 = LibcallImpls<(add ldexpf), isNotOSWindowsOrIsCygwinMinGW>;
@@ -1290,7 +1323,7 @@ def AArch64SystemLibrary : SystemRuntimeLibrary<
12901323

12911324
// Prepend a # to every name
12921325
defset list<RuntimeLibcallImpl> WinArm64ECDefaultRuntimeLibcallImpls = {
1293-
foreach libcall = WinDefaultLibcallImpls in {
1326+
foreach libcall = WinDefaultLibcallImplsBaseList in {
12941327
def arm64ec_#libcall : DuplicateLibcallImplWithPrefix<libcall, "#">;
12951328
}
12961329

@@ -1301,12 +1334,32 @@ defset list<RuntimeLibcallImpl> WinArm64ECDefaultRuntimeLibcallImpls = {
13011334

13021335
def arm64ec___stack_chk_fail : DuplicateLibcallImplWithPrefix<__stack_chk_fail, "#">;
13031336

1337+
defset list<RuntimeLibcallImpl> WinArm64ECDefaultExceptionHandlingLibcalls = {
1338+
foreach libcall = DefaultExceptionHandlingLibcalls in {
1339+
def arm64ec_#libcall : DuplicateLibcallImplWithPrefix<libcall, "#">;
1340+
}
1341+
}
1342+
1343+
defset list<RuntimeLibcallImpl> WinArm64ECSjLjExceptionHandlingLibcalls = {
1344+
foreach libcall = SjLjExceptionHandlingLibcalls in {
1345+
def arm64ec_#libcall : DuplicateLibcallImplWithPrefix<libcall, "#">;
1346+
}
1347+
}
1348+
1349+
defvar ExceptionModelCallsArm64EC = (add
1350+
LibcallImpls<(add WinArm64ECDefaultExceptionHandlingLibcalls),
1351+
ExceptionModelIsNotNone>,
1352+
LibcallImpls<(add WinArm64ECSjLjExceptionHandlingLibcalls),
1353+
ExceptionModelIsSjLj>
1354+
);
1355+
13041356
def WindowsARM64ECSystemLibrary
13051357
: SystemRuntimeLibrary<isWindowsArm64EC,
13061358
(add WinArm64ECDefaultRuntimeLibcallImpls,
13071359
arm64ec___stack_chk_fail,
13081360
LibcallImpls<(add __security_check_cookie_arm64ec),
1309-
isWindowsMSVCEnvironment>)>;
1361+
isWindowsMSVCEnvironment>,
1362+
ExceptionModelCallsArm64EC)>;
13101363

13111364
//===----------------------------------------------------------------------===//
13121365
// AMDGPU Runtime Libcalls
@@ -2345,7 +2398,7 @@ defvar X86CommonLibcalls =
23452398
// hack for one test relying on it.
23462399
__powitf2_f128,
23472400
DefaultStackProtector
2348-
);
2401+
);
23492402

23502403
defvar Windows32DivRemMulCalls =
23512404
LibcallsWithCC<(add WindowsDivRemMulLibcalls), X86_STDCALL,
@@ -2489,6 +2542,7 @@ def WasmSystemLibrary
24892542
(add DefaultRuntimeLibcallImpls, Int128RTLibcalls,
24902543
CompilerRTOnlyInt64Libcalls, CompilerRTOnlyInt128Libcalls,
24912544
exp10f, exp10,
2545+
_Unwind_CallPersonality,
24922546
emscripten_return_address,
24932547
__stack_chk_fail)>;
24942548

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
3131
ExceptionHandling ExceptionModel,
3232
FloatABI::ABIType FloatABI,
3333
EABI EABIVersion, StringRef ABIName) {
34-
setTargetRuntimeLibcallSets(TT, FloatABI, EABIVersion, ABIName);
35-
36-
if (ExceptionModel == ExceptionHandling::SjLj)
37-
setLibcallImpl(RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
34+
setTargetRuntimeLibcallSets(TT, ExceptionModel, FloatABI, EABIVersion,
35+
ABIName);
3836

3937
if (TT.isARM() || TT.isThumb()) {
4038
// The half <-> float conversion functions are always soft-float on

llvm/test/TableGen/RuntimeLibcallEmitter-calling-conv.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def MSP430LibraryWithCondCC : SystemRuntimeLibrary<isMSP430,
4141
>;
4242

4343

44-
// CHECK: void llvm::RTLIB::RuntimeLibcallsInfo::setTargetRuntimeLibcallSets(const llvm::Triple &TT, FloatABI::ABIType FloatABI, EABI EABIVersion, StringRef ABIName) {
44+
// CHECK: void llvm::RTLIB::RuntimeLibcallsInfo::setTargetRuntimeLibcallSets(const llvm::Triple &TT, ExceptionHandling ExceptionModel, FloatABI::ABIType FloatABI, EABI EABIVersion, StringRef ABIName) {
4545
// CHECK: if (TT.getArch() == Triple::avr && TT.isOSHurd()) {
4646
// CHECK-NEXT: const CallingConv::ID DefaultCC = isFoo() ? CallingConv::Fast : CallingConv::GHC;
4747
// CHECK-NEXT: for (CallingConv::ID &Entry : LibcallImplCallingConvs) {

llvm/test/TableGen/RuntimeLibcallEmitter.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def BlahLibrary : SystemRuntimeLibrary<isBlahArch, (add calloc, LibraryWithCondi
189189
// CHECK: return enum_seq(RTLIB::Unsupported, RTLIB::Unsupported);
190190
// CHECK-NEXT: }
191191

192-
// CHECK: void llvm::RTLIB::RuntimeLibcallsInfo::setTargetRuntimeLibcallSets(const llvm::Triple &TT, FloatABI::ABIType FloatABI, EABI EABIVersion, StringRef ABIName) {
192+
// CHECK: void llvm::RTLIB::RuntimeLibcallsInfo::setTargetRuntimeLibcallSets(const llvm::Triple &TT, ExceptionHandling ExceptionModel, FloatABI::ABIType FloatABI, EABI EABIVersion, StringRef ABIName) {
193193
// CHECK-NEXT: struct LibcallImplPair {
194194
// CHECK-NEXT: RTLIB::Libcall Func;
195195
// CHECK-NEXT: RTLIB::LibcallImpl Impl;

llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@ const uint8_t RTLIB::RuntimeLibcallsInfo::RuntimeLibcallNameSizeTable[] = {
550550
void RuntimeLibcallEmitter::emitSystemRuntimeLibrarySetCalls(
551551
raw_ostream &OS) const {
552552
OS << "void llvm::RTLIB::RuntimeLibcallsInfo::setTargetRuntimeLibcallSets("
553-
"const llvm::Triple &TT, FloatABI::ABIType FloatABI, EABI EABIVersion, "
553+
"const llvm::Triple &TT, ExceptionHandling ExceptionModel, "
554+
"FloatABI::ABIType FloatABI, EABI EABIVersion, "
554555
"StringRef ABIName) {\n"
555556
" struct LibcallImplPair {\n"
556557
" RTLIB::Libcall Func;\n"

0 commit comments

Comments
 (0)