aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-04-10 20:55:44 +0200
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-04-10 20:55:44 +0200
commit50d59f7ab7ae06de2ae6439752f0b56695d539df (patch)
treed625542a64dff9eeabc07678ad82cd21ade585b8
parentb19b9defebf96ba8599f481d4c617d43c21642ef (diff)
downloadcompcert-kvx-50d59f7ab7ae06de2ae6439752f0b56695d539df.tar.gz
compcert-kvx-50d59f7ab7ae06de2ae6439752f0b56695d539df.zip
fix writing profiling info for Aarch64
-rw-r--r--aarch64/TargetPrinter.ml8
-rw-r--r--backend/PrintAsmaux.ml39
-rw-r--r--mppa_k1c/TargetPrinter.ml2
3 files changed, 38 insertions, 11 deletions
diff --git a/aarch64/TargetPrinter.ml b/aarch64/TargetPrinter.ml
index 9d605336..5f62c936 100644
--- a/aarch64/TargetPrinter.ml
+++ b/aarch64/TargetPrinter.ml
@@ -608,9 +608,15 @@ module Target : TARGET =
fprintf oc " add x1, x1, :lo12:%s\n" profiling_id_table_name;
fprintf oc " mov w0, %d\n" nr_items;
fprintf oc " b %s\n" profiling_write_table_helper ;;
+
+ let print_atexit oc to_be_called =
+ fprintf oc " adrp x0, %s\n" to_be_called;
+ fprintf oc " add x0, x0, :lo12:%s\n" to_be_called;
+ fprintf oc " b atexit\n";;
+
let print_epilogue oc =
- print_profiling fini_section aarch64_profiling_stub oc;
+ print_profiling_epilogue (Init_atexit print_atexit) aarch64_profiling_stub oc;
if !Clflags.option_g then begin
Debug.compute_gnu_file_enum (fun f -> ignore (print_file oc f));
section oc Section_text;
diff --git a/backend/PrintAsmaux.ml b/backend/PrintAsmaux.ml
index 5a074867..c7161615 100644
--- a/backend/PrintAsmaux.ml
+++ b/backend/PrintAsmaux.ml
@@ -342,12 +342,27 @@ let print_profiling_id oc id =
let profiling_counter_table_name = ".compcert_profiling_counters"
and profiling_id_table_name = ".compcert_profiling_ids"
-and profiling_write_table = ".compcert_profiling_write_table"
+and profiling_write_table = ".compcert_profiling_save_for_this_object"
+and profiling_init = ".compcert_profiling_init"
and profiling_write_table_helper = "_compcert_write_profiling_table"
and dtor_section = ".dtors.65435,\"aw\",@progbits"
-and fini_section = ".fini_array.00100,\"aw\"";;
+(* and fini_section = ".fini_array_00100,\"aw\"" *)
+and init_section = ".init_array,\"aw\"";;
-let print_profiling finalizer_section print_profiling_stub oc =
+type finalizer_call_method =
+ | Dtors
+ | Init_atexit of (out_channel -> string -> unit);;
+
+let write_symbol_pointer oc sym =
+ if Archi.ptr64
+ then fprintf oc " .8byte %s\n" sym
+ else fprintf oc " .4byte %s\n" sym;;
+
+let declare_function oc name =
+ fprintf oc " .type %s, @function\n" name;
+ fprintf oc " .size %s, . - %s\n" name name;;
+
+let print_profiling_epilogue finalizer_call_method print_profiling_stub oc =
let nr_items = !next_profiling_position in
if nr_items > 0
then
@@ -362,12 +377,18 @@ let print_profiling finalizer_section print_profiling_stub oc =
print_profiling_stub oc nr_items
profiling_id_table_name
profiling_counter_table_name;
- fprintf oc " .type %s, @function\n" profiling_write_table;
- fprintf oc " .size %s, . - %s\n" profiling_write_table profiling_write_table;
- fprintf oc " .section %s\n" finalizer_section;
- (if Archi.ptr64
- then fprintf oc " .8byte %s\n" profiling_write_table
- else fprintf oc " .4byte %s\n" profiling_write_table)
+ declare_function oc profiling_write_table;
+ match finalizer_call_method with
+ | Dtors ->
+ fprintf oc " .section %s\n" dtor_section;
+ write_symbol_pointer oc profiling_write_table
+ | Init_atexit(atexit_call) ->
+ fprintf oc " .section %s\n" init_section;
+ write_symbol_pointer oc profiling_init;
+ fprintf oc " .text\n";
+ fprintf oc "%s:\n" profiling_init;
+ atexit_call oc profiling_write_table;
+ declare_function oc profiling_init
end;;
let profiling_offset id kind =
diff --git a/mppa_k1c/TargetPrinter.ml b/mppa_k1c/TargetPrinter.ml
index 71979705..61fe5e90 100644
--- a/mppa_k1c/TargetPrinter.ml
+++ b/mppa_k1c/TargetPrinter.ml
@@ -816,7 +816,7 @@ module Target (*: TARGET*) =
end
let print_epilogue oc =
- print_profiling dtor_section k1c_profiling_stub oc;
+ print_profiling_epilogue Dtors k1c_profiling_stub oc;
if !Clflags.option_g then begin
Debug.compute_gnu_file_enum (fun f -> ignore (print_file oc f));
section oc Section_text;