File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -88,11 +88,19 @@ enum bpf_enum_value_kind {
8888 const void *p = (const void *)s + __CORE_RELO(s, field, BYTE_OFFSET); \
8989 unsigned long long val; \
9090 \
91+ /* This is a so-called barrier_var() operation that makes specified \
92+ * variable "a black box" for optimizing compiler. \
93+ * It forces compiler to perform BYTE_OFFSET relocation on p and use \
94+ * its calculated value in the switch below, instead of applying \
95+ * the same relocation 4 times for each individual memory load. \
96+ */ \
97+ asm volatile ("" : "=r" (p ) : "0" (p )); \
98+ \
9199 switch (__CORE_RELO (s , field , BYTE_SIZE )) { \
92- case 1: val = *(const unsigned char *)p; \
93- case 2: val = *(const unsigned short *)p; \
94- case 4: val = *(const unsigned int *)p; \
95- case 8: val = *(const unsigned long long *)p; \
100+ case 1 : val = * (const unsigned char * )p ; break ; \
101+ case 2 : val = * (const unsigned short * )p ; break ; \
102+ case 4 : val = * (const unsigned int * )p ; break ; \
103+ case 8 : val = * (const unsigned long long * )p ; break ; \
96104 } \
97105 val <<= __CORE_RELO (s , field , LSHIFT_U64 ); \
98106 if (__CORE_RELO (s , field , SIGNED )) \
You can’t perform that action at this time.
0 commit comments