Skip to content

Commit 149f0a8

Browse files
committed
Swap strong alias with weak function
Existing state confuses LLVM CFI. Probably we can find a fix in CFI llvm/llvm-project#150070. However, this workaround seems less confusing for humans as well, and makes code compatible with existing compilers. Before the patch the code preserved weak function body even if weak function was overridden with strong function. With the patch version we will override alias, which is more conventional. PiperOrigin-RevId: 786135294
1 parent fe16805 commit 149f0a8

File tree

5 files changed

+235
-238
lines changed

5 files changed

+235
-238
lines changed

src/legacy-api.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,35 @@
2020
#include "threadpool-common.h"
2121
#include "threadpool-utils.h"
2222

23-
PTHREADPOOL_WEAK void pthreadpool_compute_1d(pthreadpool_t threadpool,
24-
pthreadpool_function_1d_t function,
25-
void* argument, size_t range) {
23+
void PTHREADPOOL_IMPL(pthreadpool_compute_1d)(
24+
pthreadpool_t threadpool, pthreadpool_function_1d_t function,
25+
void* argument, size_t range) {
2626
pthreadpool_parallelize_1d(threadpool, (pthreadpool_task_1d_t)function,
2727
argument, range, 0 /* flags */);
2828
}
2929

30-
PTHREADPOOL_PRIVATE_IMPL(pthreadpool_compute_1d)
30+
PTHREADPOOL_WEAK_ALIAS(pthreadpool_compute_1d)
3131

32-
PTHREADPOOL_WEAK void pthreadpool_compute_1d_tiled(
32+
void PTHREADPOOL_IMPL(pthreadpool_compute_1d_tiled)(
3333
pthreadpool_t threadpool, pthreadpool_function_1d_tiled_t function,
3434
void* argument, size_t range, size_t tile) {
3535
pthreadpool_parallelize_1d_tile_1d(threadpool,
3636
(pthreadpool_task_1d_tile_1d_t)function,
3737
argument, range, tile, 0 /* flags */);
3838
}
3939

40-
PTHREADPOOL_PRIVATE_IMPL(pthreadpool_compute_1d_tiled)
40+
PTHREADPOOL_WEAK_ALIAS(pthreadpool_compute_1d_tiled)
4141

42-
PTHREADPOOL_WEAK void pthreadpool_compute_2d(pthreadpool_t threadpool,
43-
pthreadpool_function_2d_t function,
44-
void* argument, size_t range_i,
45-
size_t range_j) {
42+
void PTHREADPOOL_IMPL(pthreadpool_compute_2d)(
43+
pthreadpool_t threadpool, pthreadpool_function_2d_t function,
44+
void* argument, size_t range_i, size_t range_j) {
4645
pthreadpool_parallelize_2d(threadpool, (pthreadpool_task_2d_t)function,
4746
argument, range_i, range_j, 0 /* flags */);
4847
}
4948

50-
PTHREADPOOL_PRIVATE_IMPL(pthreadpool_compute_2d)
49+
PTHREADPOOL_WEAK_ALIAS(pthreadpool_compute_2d)
5150

52-
PTHREADPOOL_WEAK void pthreadpool_compute_2d_tiled(
51+
void PTHREADPOOL_IMPL(pthreadpool_compute_2d_tiled)(
5352
pthreadpool_t threadpool, pthreadpool_function_2d_tiled_t function,
5453
void* argument, size_t range_i, size_t range_j, size_t tile_i,
5554
size_t tile_j) {
@@ -58,7 +57,7 @@ PTHREADPOOL_WEAK void pthreadpool_compute_2d_tiled(
5857
range_j, tile_i, tile_j, 0 /* flags */);
5958
}
6059

61-
PTHREADPOOL_PRIVATE_IMPL(pthreadpool_compute_2d_tiled)
60+
PTHREADPOOL_WEAK_ALIAS(pthreadpool_compute_2d_tiled)
6261

6362
struct compute_3d_tiled_context {
6463
pthreadpool_function_3d_tiled_t function;
@@ -94,7 +93,7 @@ static void compute_3d_tiled(const struct compute_3d_tiled_context* context,
9493
tile_j, tile_k);
9594
}
9695

97-
PTHREADPOOL_WEAK void pthreadpool_compute_3d_tiled(
96+
void PTHREADPOOL_IMPL(pthreadpool_compute_3d_tiled)(
9897
pthreadpool_t threadpool, pthreadpool_function_3d_tiled_t function,
9998
void* argument, size_t range_i, size_t range_j, size_t range_k,
10099
size_t tile_i, size_t tile_j, size_t tile_k) {
@@ -131,7 +130,7 @@ PTHREADPOOL_WEAK void pthreadpool_compute_3d_tiled(
131130
}
132131
}
133132

134-
PTHREADPOOL_PRIVATE_IMPL(pthreadpool_compute_3d_tiled)
133+
PTHREADPOOL_WEAK_ALIAS(pthreadpool_compute_3d_tiled)
135134

136135
struct compute_4d_tiled_context {
137136
pthreadpool_function_4d_tiled_t function;
@@ -176,7 +175,7 @@ static void compute_4d_tiled(const struct compute_4d_tiled_context* context,
176175
tile_i, tile_j, tile_k, tile_l);
177176
}
178177

179-
PTHREADPOOL_WEAK void pthreadpool_compute_4d_tiled(
178+
void PTHREADPOOL_IMPL(pthreadpool_compute_4d_tiled)(
180179
pthreadpool_t threadpool, pthreadpool_function_4d_tiled_t function,
181180
void* argument, size_t range_i, size_t range_j, size_t range_k,
182181
size_t range_l, size_t tile_i, size_t tile_j, size_t tile_k,
@@ -222,4 +221,4 @@ PTHREADPOOL_WEAK void pthreadpool_compute_4d_tiled(
222221
}
223222
}
224223

225-
PTHREADPOOL_PRIVATE_IMPL(pthreadpool_compute_4d_tiled)
224+
PTHREADPOOL_WEAK_ALIAS(pthreadpool_compute_4d_tiled)

0 commit comments

Comments
 (0)