Skip to content

Commit bc1071d

Browse files
committed
[IRGen] Factor out this function.
1 parent df273d6 commit bc1071d

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

lib/IRGen/GenCoro.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,13 @@ static llvm::Constant *getAddrOfGlobalCoroAllocator(
10831083
return taskAllocator;
10841084
}
10851085

1086+
static llvm::Constant *getAddrOfGlobalCoroAllocator(
1087+
IRGenModule &IGM, CoroAllocatorKind kind, bool shouldDeallocateImmediately,
1088+
llvm::Constant *allocFn, llvm::Constant *deallocFn) {
1089+
return getAddrOfGlobalCoroAllocator(IGM, kind, shouldDeallocateImmediately,
1090+
allocFn, deallocFn, allocFn, deallocFn);
1091+
}
1092+
10861093
static llvm::Constant *getAddrOfSwiftCoroMalloc(
10871094
IRGenModule &IGM) {
10881095
return getAddrOfSwiftCoroAllocThunk("_swift_coro_malloc",
@@ -1098,13 +1105,10 @@ static llvm::Constant *getAddrOfSwiftCoroFree(
10981105
}
10991106

11001107
llvm::Constant *IRGenModule::getAddrOfGlobalCoroMallocAllocator() {
1101-
return getAddrOfGlobalCoroAllocator(
1102-
*this, CoroAllocatorKind::Malloc,
1103-
/*shouldDeallocateImmediately=*/true,
1104-
getAddrOfSwiftCoroMalloc(*this),
1105-
getAddrOfSwiftCoroFree(*this),
1106-
getAddrOfSwiftCoroMalloc(*this),
1107-
getAddrOfSwiftCoroFree(*this));
1108+
return getAddrOfGlobalCoroAllocator(*this, CoroAllocatorKind::Malloc,
1109+
/*shouldDeallocateImmediately=*/true,
1110+
getAddrOfSwiftCoroMalloc(*this),
1111+
getAddrOfSwiftCoroFree(*this));
11081112
}
11091113

11101114
static llvm::Constant *
@@ -1122,13 +1126,10 @@ getAddrOfSwiftCoroTaskDealloc(IRGenModule &IGM) {
11221126
}
11231127

11241128
llvm::Constant *IRGenModule::getAddrOfGlobalCoroAsyncTaskAllocator() {
1125-
return getAddrOfGlobalCoroAllocator(
1126-
*this, CoroAllocatorKind::Async,
1127-
/*shouldDeallocateImmediately=*/false,
1128-
getAddrOfSwiftCoroTaskAlloc(*this),
1129-
getAddrOfSwiftCoroTaskDealloc(*this),
1130-
getAddrOfSwiftCoroTaskAlloc(*this),
1131-
getAddrOfSwiftCoroTaskDealloc(*this));
1129+
return getAddrOfGlobalCoroAllocator(*this, CoroAllocatorKind::Async,
1130+
/*shouldDeallocateImmediately=*/false,
1131+
getAddrOfSwiftCoroTaskAlloc(*this),
1132+
getAddrOfSwiftCoroTaskDealloc(*this));
11321133
}
11331134

11341135
llvm::Value *

0 commit comments

Comments
 (0)