Skip to content

Commit 7d4b789

Browse files
pranavkGramner
authored andcommitted
Mark C globals with small code model
We have new option in clang (llvm/llvm-project#124834) to mark globals to be allocated in non-large sections. We can mark all globals that are referenced from hardcoded assembly (which implicitly references globals assuming they are in non-large sections) with this attribute to avoid running into problems when dav1d is built with -mcmodel=medium with clang.
1 parent 42b2b24 commit 7d4b789

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

include/common/attributes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@
123123
#define EXTERN extern
124124
#endif
125125

126+
#if ARCH_X86_64 && __has_attribute(model)
127+
#define ATTR_MCMODEL_SMALL __attribute__((model("small")))
128+
#else
129+
#define ATTR_MCMODEL_SMALL
130+
#endif
131+
126132
#ifdef __clang__
127133
#define NO_SANITIZE(x) __attribute__((no_sanitize(x)))
128134
#else

src/tables.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ const uint16_t ALIGN(dav1d_sgr_params[16][2], 4) = {
419419
{ 0, 1177 }, { 0, 925 }, { 56, 0 }, { 22, 0 },
420420
};
421421

422+
ATTR_MCMODEL_SMALL
422423
const uint8_t ALIGN(dav1d_sgr_x_by_x[256], 64) = {
423424
255, 128, 85, 64, 51, 43, 37, 32, 28, 26, 23, 21, 20, 18, 17,
424425
16, 15, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 9, 9,
@@ -440,6 +441,7 @@ const uint8_t ALIGN(dav1d_sgr_x_by_x[256], 64) = {
440441
0
441442
};
442443

444+
ATTR_MCMODEL_SMALL
443445
const int8_t ALIGN(dav1d_mc_subpel_filters[6][15][8], 8) = {
444446
[DAV1D_FILTER_8TAP_REGULAR] = {
445447
{ 0, 1, -3, 63, 4, -1, 0, 0 },
@@ -544,6 +546,7 @@ const int8_t ALIGN(dav1d_mc_subpel_filters[6][15][8], 8) = {
544546
}
545547
};
546548

549+
ATTR_MCMODEL_SMALL
547550
const int8_t ALIGN(dav1d_mc_warp_filter[193][8], 8) = {
548551
// [-1, 0)
549552
{ 0, 0, 127, 1, 0, 0, 0, 0 }, { 0, -1, 127, 2, 0, 0, 0, 0 },
@@ -648,6 +651,7 @@ const int8_t ALIGN(dav1d_mc_warp_filter[193][8], 8) = {
648651
{ 0, 0, 0, 0, 2, 127, -1, 0 },
649652
};
650653

654+
ATTR_MCMODEL_SMALL
651655
const int8_t ALIGN(dav1d_resize_filter[64][8], 8) = {
652656
{ 0, 0, 0, -128, 0, 0, 0, 0 }, { 0, 0, 1, -128, -2, 1, 0, 0 },
653657
{ 0, -1, 3, -127, -4, 2, -1, 0 }, { 0, -1, 4, -127, -6, 3, -1, 0 },
@@ -711,6 +715,7 @@ const uint8_t ALIGN(dav1d_sm_weights[128], 16) = {
711715
7, 6, 6, 5, 5, 4, 4, 4
712716
};
713717

718+
ATTR_MCMODEL_SMALL
714719
const uint16_t dav1d_dr_intra_derivative[44] = {
715720
// Values that are 0 will never be used
716721
0, // Angles:
@@ -756,6 +761,7 @@ const uint16_t dav1d_dr_intra_derivative[44] = {
756761
[1*idx+32] = f4, [1*idx+40] = f5, \
757762
[1*idx+48] = f6
758763
#endif
764+
ATTR_MCMODEL_SMALL
759765
const int8_t ALIGN(dav1d_filter_intra_taps[5][64], 64) = {
760766
{
761767
F( 0, -6, 10, 0, 0, 0, 12, 0 ),
@@ -822,6 +828,7 @@ const uint8_t ALIGN(dav1d_obmc_masks[64], 16) = {
822828
};
823829

824830
// Taken from the spec. Range is [-2048, 2047], mean is 0 and stddev is 512
831+
ATTR_MCMODEL_SMALL
825832
const int16_t dav1d_gaussian_sequence[2048] = {
826833
56, 568, -180, 172, 124, -84, 172, -64, -900, 24, 820,
827834
224, 1248, 996, 272, -8, -916, -388, -732, -104, -188, 800,

0 commit comments

Comments
 (0)