https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112634

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Breakpoint 6, gen_assign_counter_update (gsi=0x7fffffffcab0,
call=0x7ffff7230b48, func=0x7ffff736cb00, result=0x7ffff7200b98, name=0x258f5f2
"PROF_time_profile") at ../../../repos/gcc/gcc/tree-profile.cc:247

(gdb) p debug_gimple_stmt(call)
__atomic_add_fetch_8 (&__gcov_time_profiler_counter, 1, 0);

(gdb) p debug_tree(result)
 <array_ref 0x7ffff7200b98
    type <integer_type 0x7ffff7221738 long int public DI
...
    arg:0 <var_decl 0x7ffff73f4990 __gcov7.main._omp_fn.0
        type <array_type 0x7ffff73f3690 type <integer_type 0x7ffff7221738 long
int>
            BLK

(gdb) p debug_tree(func)
 <function_decl 0x7ffff736cb00 __atomic_add_fetch_8
    type <function_type 0x7ffff7245f18
        type <integer_type 0x7ffff72217e0 long unsigned int public unsigned DI

* * *

The commit changed:

-      gcall *stmt = gimple_build_call (f, 3, addr, one,
-                                      build_int_cst (integer_type_node,
-                                                     MEMMODEL_RELAXED));
-      gsi_insert_on_edge (e, stmt);
+      tree f = builtin_decl_explicit (TYPE_PRECISION (type) > 32
+                                     ? BUILT_IN_ATOMIC_ADD_FETCH_8:
+                                     BUILT_IN_ATOMIC_ADD_FETCH_4);
+      gcall *call = gimple_build_call (f, 3, addr, one, relaxed);
+      gen_assign_counter_update (gsi, call, f, result, name);

with the new gen_assign_counter_update:

+  if (result)
+    {
+      tree result_type = TREE_TYPE (TREE_TYPE (func));

+      tree tmp = make_temp_ssa_name (result_type, NULL, name);
+      gimple_set_lhs (call, tmp);
+      gsi_insert_after (gsi, call, GSI_NEW_STMT);
+      gassign *assign = gimple_build_assign (result, tmp);
+      gsi_insert_after (gsi, assign, GSI_NEW_STMT);

* * *

Thus, it looks as if f's alias func's 'result_type' is unsigned while the rest
is all signed.

Reply via email to