Skip to content

Commit 3f8c743

Browse files
committed
IRGen: Centralize logic that decides whether the platform suppports typed malloc
NFC intended
1 parent 77eb4f0 commit 3f8c743

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3789,10 +3789,15 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
37893789
Args.hasFlag(OPT_enable_async_frame_push_pop_metadata,
37903790
OPT_disable_async_frame_push_pop_metadata,
37913791
Opts.EmitAsyncFramePushPopMetadata);
3792+
3793+
bool platformSupportsTypedMalloc = !llvm::Triple(Triple).isOSLinux() &&
3794+
!llvm::Triple(Triple).isOSWindows();
3795+
37923796
Opts.EmitTypeMallocForCoroFrame =
37933797
Args.hasFlag(OPT_enable_emit_type_malloc_for_coro_frame,
37943798
OPT_disable_emit_type_malloc_for_coro_frame,
3795-
Opts.EmitTypeMallocForCoroFrame);
3799+
(Opts.EmitTypeMallocForCoroFrame && platformSupportsTypedMalloc));
3800+
37963801
Opts.AsyncFramePointerAll = Args.hasFlag(OPT_enable_async_frame_pointer_all,
37973802
OPT_disable_async_frame_pointer_all,
37983803
Opts.AsyncFramePointerAll);

lib/IRGen/GenCall.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5117,9 +5117,7 @@ void irgen::emitYieldOnceCoroutineEntry(
51175117
auto *buffer = emission.getCoroutineBuffer();
51185118
llvm::SmallVector<llvm::Value *, 2> finalArgs;
51195119
llvm::Constant *allocFn = nullptr;
5120-
if (IGF.getOptions().EmitTypeMallocForCoroFrame
5121-
&& !llvm::Triple(IGF.IGM.Triple).isOSLinux()
5122-
&& !llvm::Triple(IGF.IGM.Triple).isOSWindows()) {
5120+
if (IGF.getOptions().EmitTypeMallocForCoroFrame) {
51235121
auto mallocTypeId = IGF.getMallocTypeId();
51245122
finalArgs.push_back(mallocTypeId);
51255123
// Use swift_coroFrameAllocStub to emit our allocator.

lib/IRGen/GenFunc.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,9 +1499,7 @@ class CoroPartialApplicationForwarderEmission
14991499
// Call the right 'llvm.coro.id.retcon' variant.
15001500
llvm::Value *buffer = origParams.claimNext();
15011501
llvm::Value *id;
1502-
if (subIGF.IGM.getOptions().EmitTypeMallocForCoroFrame
1503-
&& !llvm::Triple(subIGF.IGM.Triple).isOSLinux()
1504-
&& !llvm::Triple(subIGF.IGM.Triple).isOSWindows()) {
1502+
if (subIGF.IGM.getOptions().EmitTypeMallocForCoroFrame) {
15051503
// Use swift_coroFrameAllocStub to emit our allocator.
15061504
auto coroAllocFn = subIGF.IGM.getOpaquePtr(getCoroFrameAllocStubFn(subIGF.IGM));
15071505
auto mallocTypeId = subIGF.getMallocTypeId();

0 commit comments

Comments
 (0)