Skip to content

Commit 7d72959

Browse files
Merge pull request #81037 from aschwaighofer/irgen_coroFrameAlloc_cleanup
IRGen: Centralize logic that decides whether the platform suppports typed malloc
2 parents 1af98f7 + 3f8c743 commit 7d72959

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
@@ -3781,10 +3781,15 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
37813781
Args.hasFlag(OPT_enable_async_frame_push_pop_metadata,
37823782
OPT_disable_async_frame_push_pop_metadata,
37833783
Opts.EmitAsyncFramePushPopMetadata);
3784+
3785+
bool platformSupportsTypedMalloc = !llvm::Triple(Triple).isOSLinux() &&
3786+
!llvm::Triple(Triple).isOSWindows();
3787+
37843788
Opts.EmitTypeMallocForCoroFrame =
37853789
Args.hasFlag(OPT_enable_emit_type_malloc_for_coro_frame,
37863790
OPT_disable_emit_type_malloc_for_coro_frame,
3787-
Opts.EmitTypeMallocForCoroFrame);
3791+
(Opts.EmitTypeMallocForCoroFrame && platformSupportsTypedMalloc));
3792+
37883793
Opts.AsyncFramePointerAll = Args.hasFlag(OPT_enable_async_frame_pointer_all,
37893794
OPT_disable_async_frame_pointer_all,
37903795
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)