hc
2024-05-10 748e4f3d702def1a4bff191e0cf93b6a05340f01
kernel/kernel/gcov/clang.c
....@@ -70,12 +70,16 @@
7070
7171 u32 ident;
7272 u32 checksum;
73
+#if CONFIG_CLANG_VERSION < 110000
7374 u8 use_extra_checksum;
75
+#endif
7476 u32 cfg_checksum;
7577
7678 u32 num_counters;
7779 u64 *counters;
80
+#if CONFIG_CLANG_VERSION < 110000
7881 const char *function_name;
82
+#endif
7983 };
8084
8185 static struct gcov_info *current_info;
....@@ -105,6 +109,7 @@
105109 }
106110 EXPORT_SYMBOL(llvm_gcov_init);
107111
112
+#if CONFIG_CLANG_VERSION < 110000
108113 void llvm_gcda_start_file(const char *orig_filename, const char version[4],
109114 u32 checksum)
110115 {
....@@ -113,7 +118,17 @@
113118 current_info->checksum = checksum;
114119 }
115120 EXPORT_SYMBOL(llvm_gcda_start_file);
121
+#else
122
+void llvm_gcda_start_file(const char *orig_filename, u32 version, u32 checksum)
123
+{
124
+ current_info->filename = orig_filename;
125
+ current_info->version = version;
126
+ current_info->checksum = checksum;
127
+}
128
+EXPORT_SYMBOL(llvm_gcda_start_file);
129
+#endif
116130
131
+#if CONFIG_CLANG_VERSION < 110000
117132 void llvm_gcda_emit_function(u32 ident, const char *function_name,
118133 u32 func_checksum, u8 use_extra_checksum, u32 cfg_checksum)
119134 {
....@@ -132,6 +147,21 @@
132147
133148 list_add_tail(&info->head, &current_info->functions);
134149 }
150
+#else
151
+void llvm_gcda_emit_function(u32 ident, u32 func_checksum, u32 cfg_checksum)
152
+{
153
+ struct gcov_fn_info *info = kzalloc(sizeof(*info), GFP_KERNEL);
154
+
155
+ if (!info)
156
+ return;
157
+
158
+ INIT_LIST_HEAD(&info->head);
159
+ info->ident = ident;
160
+ info->checksum = func_checksum;
161
+ info->cfg_checksum = cfg_checksum;
162
+ list_add_tail(&info->head, &current_info->functions);
163
+}
164
+#endif
135165 EXPORT_SYMBOL(llvm_gcda_emit_function);
136166
137167 void llvm_gcda_emit_arcs(u32 num_counters, u64 *counters)
....@@ -262,11 +292,16 @@
262292 !list_is_last(&fn_ptr2->head, &info2->functions)) {
263293 if (fn_ptr1->checksum != fn_ptr2->checksum)
264294 return false;
295
+#if CONFIG_CLANG_VERSION < 110000
265296 if (fn_ptr1->use_extra_checksum != fn_ptr2->use_extra_checksum)
266297 return false;
267298 if (fn_ptr1->use_extra_checksum &&
268299 fn_ptr1->cfg_checksum != fn_ptr2->cfg_checksum)
269300 return false;
301
+#else
302
+ if (fn_ptr1->cfg_checksum != fn_ptr2->cfg_checksum)
303
+ return false;
304
+#endif
270305 fn_ptr1 = list_next_entry(fn_ptr1, head);
271306 fn_ptr2 = list_next_entry(fn_ptr2, head);
272307 }
....@@ -292,9 +327,12 @@
292327
293328 for (i = 0; i < sfn_ptr->num_counters; i++)
294329 dfn_ptr->counters[i] += sfn_ptr->counters[i];
330
+
331
+ sfn_ptr = list_next_entry(sfn_ptr, head);
295332 }
296333 }
297334
335
+#if CONFIG_CLANG_VERSION < 110000
298336 static struct gcov_fn_info *gcov_fn_info_dup(struct gcov_fn_info *fn)
299337 {
300338 size_t cv_size; /* counter values size */
....@@ -322,6 +360,28 @@
322360 kfree(fn_dup);
323361 return NULL;
324362 }
363
+#else
364
+static struct gcov_fn_info *gcov_fn_info_dup(struct gcov_fn_info *fn)
365
+{
366
+ size_t cv_size; /* counter values size */
367
+ struct gcov_fn_info *fn_dup = kmemdup(fn, sizeof(*fn),
368
+ GFP_KERNEL);
369
+ if (!fn_dup)
370
+ return NULL;
371
+ INIT_LIST_HEAD(&fn_dup->head);
372
+
373
+ cv_size = fn->num_counters * sizeof(fn->counters[0]);
374
+ fn_dup->counters = vmalloc(cv_size);
375
+ if (!fn_dup->counters) {
376
+ kfree(fn_dup);
377
+ return NULL;
378
+ }
379
+
380
+ memcpy(fn_dup->counters, fn->counters, cv_size);
381
+
382
+ return fn_dup;
383
+}
384
+#endif
325385
326386 /**
327387 * gcov_info_dup - duplicate profiling data set
....@@ -362,6 +422,7 @@
362422 * gcov_info_free - release memory for profiling data set duplicate
363423 * @info: profiling data set duplicate to free
364424 */
425
+#if CONFIG_CLANG_VERSION < 110000
365426 void gcov_info_free(struct gcov_info *info)
366427 {
367428 struct gcov_fn_info *fn, *tmp;
....@@ -375,6 +436,20 @@
375436 kfree(info->filename);
376437 kfree(info);
377438 }
439
+#else
440
+void gcov_info_free(struct gcov_info *info)
441
+{
442
+ struct gcov_fn_info *fn, *tmp;
443
+
444
+ list_for_each_entry_safe(fn, tmp, &info->functions, head) {
445
+ vfree(fn->counters);
446
+ list_del(&fn->head);
447
+ kfree(fn);
448
+ }
449
+ kfree(info->filename);
450
+ kfree(info);
451
+}
452
+#endif
378453
379454 #define ITER_STRIDE PAGE_SIZE
380455
....@@ -460,17 +535,22 @@
460535
461536 list_for_each_entry(fi_ptr, &info->functions, head) {
462537 u32 i;
463
- u32 len = 2;
464
-
465
- if (fi_ptr->use_extra_checksum)
466
- len++;
467538
468539 pos += store_gcov_u32(buffer, pos, GCOV_TAG_FUNCTION);
469
- pos += store_gcov_u32(buffer, pos, len);
540
+#if CONFIG_CLANG_VERSION < 110000
541
+ pos += store_gcov_u32(buffer, pos,
542
+ fi_ptr->use_extra_checksum ? 3 : 2);
543
+#else
544
+ pos += store_gcov_u32(buffer, pos, 3);
545
+#endif
470546 pos += store_gcov_u32(buffer, pos, fi_ptr->ident);
471547 pos += store_gcov_u32(buffer, pos, fi_ptr->checksum);
548
+#if CONFIG_CLANG_VERSION < 110000
472549 if (fi_ptr->use_extra_checksum)
473550 pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum);
551
+#else
552
+ pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum);
553
+#endif
474554
475555 pos += store_gcov_u32(buffer, pos, GCOV_TAG_COUNTER_BASE);
476556 pos += store_gcov_u32(buffer, pos, fi_ptr->num_counters * 2);