Skip to content

Commit 76bf9f4

Browse files
committed
IRGen: Remove heap allocation of std::thread
1 parent fbd7949 commit 76bf9f4

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/IRGen/IRGen.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -880,14 +880,11 @@ struct LLVMCodeGenThreads {
880880
#ifdef __APPLE__
881881
pthread_t threadId;
882882
#else
883-
std::thread *thread;
883+
std::thread thread;
884884
#endif
885885

886886
Thread(LLVMCodeGenThreads &parent, unsigned threadIndex)
887887
: parent(parent), threadIndex(threadIndex)
888-
#ifndef __APPLE__
889-
, thread(nullptr)
890-
#endif
891888
{}
892889

893890
/// Run llvm codegen.
@@ -951,7 +948,7 @@ struct LLVMCodeGenThreads {
951948
pthread_attr_destroy(&stackSizeAttribute);
952949
#else
953950
for (auto &thread : threads) {
954-
thread.thread = new std::thread(runThread, &thread);
951+
thread.thread = std::thread(runThread, &thread);
955952
}
956953
#endif
957954

@@ -968,8 +965,7 @@ struct LLVMCodeGenThreads {
968965
pthread_join(thread.threadId, 0);
969966
#else
970967
for (auto &thread: threads) {
971-
thread.thread->join();
972-
delete thread.thread;
968+
thread.thread.join();
973969
}
974970
#endif
975971
}

0 commit comments

Comments
 (0)