OPMD Task_Handles

2022-05-31 Thread Yousssef Magdy via Gcc
hello there,
I am currently implementing the ompd lib as a graduation project with
Mohamed Atef, I am Facing some problems such as:
- in  ompd_get_scheduling_task_handle
 that
is supposed to get the task was active when the task that represents
task_handle was scheduled, which is still on the stack of execution on the
same thread. I see that there is some scheduling point, such that barriers
and taskwaits.
so is there any hint of how can i get the scheduling_task?
- the other function ompd_get_task_frame

should get the task exit_frame and enter_frame that point to the address of
 ompt_frame_t

which
is dependent on ompt lib,  how could I implement it?
thanks in future


Re: CFI for saved argument registers

2022-05-31 Thread Andreas Krebbel via Gcc
On 5/16/22 08:29, Andreas Krebbel via Gcc wrote:
> Hi,
> 
> I'm trying to provide a simple dwarf unwinder with access to the
> argument register content. The goal is to make this information
> available for optimized code without having to access debug
> information for things like call site args. The extra overhead
> of saving the values to the stack is acceptable in that case.
> 
> For that purpose I save the argument registers to the stack as we
> would do for a variable argument lists. But this time I also provide
> the CFI to allow the unwinder to locate the save slots.  Since I never
> actually intend to restore the content there is no matching
> cfi_restore for the cfi_offset and dwarf2cfi complains about the
> traces being inconsistent because of that. I couldn't find a way to
> prevent this.
> 
> The only way I see right now is adding a new reg note to invalidate
> the save information in the reg_save array in dwarf2cfi.
> 
> Would this be acceptable? Is there perhaps an easier way to achieve that?

Attached is a small patch adding a new reg note REG_CFA_NORESTORE.

I would attach that new note to the register save insn to indicate that this 
register will not be
restored. I'll have to emit the REG_CFA_OFFSET note as well then.

An insn saving r2-r6 without restoring them would look like this then:

(insn/f 31 21 32 2 (parallel [
(set/f (mem/c:DI (plus:DI (reg/f:DI 15 %r15)
(const_int 16 [0x10])) [4  S8 A8])
(reg:DI 2 %r2))
(set/f (mem/c:DI (plus:DI (reg/f:DI 15 %r15)
(const_int 24 [0x18])) [4  S8 A8])
(reg:DI 3 %r3))
(set/f (mem/c:DI (plus:DI (reg/f:DI 15 %r15)
(const_int 32 [0x20])) [4  S8 A8])
(reg:DI 4 %r4))
(set/f (mem/c:DI (plus:DI (reg/f:DI 15 %r15)
(const_int 40 [0x28])) [4  S8 A8])
(reg:DI 5 %r5))
(set/f (mem/c:DI (plus:DI (reg/f:DI 15 %r15)
(const_int 48 [0x30])) [4  S8 A8])
(reg:DI 6 %r6))
]) "/home/andreas/preserveargs/reduce2/t.c":2:51 -1
 (expr_list:REG_CFA_OFFSET (set (mem/c:DI (plus:DI (reg/f:DI 15 %r15)
(const_int 48 [0x30])) [4  S8 A8])
(reg:DI 6 %r6))
(expr_list:REG_CFA_NO_RESTORE (reg:DI 6 %r6)
(expr_list:REG_CFA_OFFSET (set (mem/c:DI (plus:DI (reg/f:DI 15 %r15)
(const_int 40 [0x28])) [4  S8 A8])
(reg:DI 5 %r5))
(expr_list:REG_CFA_NO_RESTORE (reg:DI 5 %r5)
(expr_list:REG_CFA_OFFSET (set (mem/c:DI (plus:DI (reg/f:DI 
15 %r15)
(const_int 32 [0x20])) [4  S8 A8])
(reg:DI 4 %r4))
(expr_list:REG_CFA_NO_RESTORE (reg:DI 4 %r4)
(expr_list:REG_CFA_OFFSET (set (mem/c:DI (plus:DI 
(reg/f:DI 15 %r15)
(const_int 24 [0x18])) [4  S8 A8])
(reg:DI 3 %r3))
(expr_list:REG_CFA_NO_RESTORE (reg:DI 3 %r3)
(expr_list:REG_CFA_OFFSET (set (mem/c:DI 
(plus:DI (reg/f:DI 15 %r15)
(const_int 16 [0x10])) [4  
S8 A8])
(reg:DI 2 %r2))
(expr_list:REG_CFA_NO_RESTORE (reg:DI 2 
%r2)
(nil

diff --git a/gcc/dwarf2cfi.c b/gcc/dwarf2cfi.c
index 362ff3fdac27..2cbc2465c3a7 100644
--- a/gcc/dwarf2cfi.c
+++ b/gcc/dwarf2cfi.c
@@ -1346,7 +1346,7 @@ dwarf2out_frame_debug_cfa_val_expression (rtx set)
 /* A subroutine of dwarf2out_frame_debug, process a REG_CFA_RESTORE note.  */

 static void
-dwarf2out_frame_debug_cfa_restore (rtx reg)
+dwarf2out_frame_debug_cfa_restore (rtx reg, bool emit_cfi)
 {
   gcc_assert (REG_P (reg));

@@ -1354,7 +1354,8 @@ dwarf2out_frame_debug_cfa_restore (rtx reg)
   if (!span)
 {
   unsigned int regno = dwf_regno (reg);
-  add_cfi_restore (regno);
+  if (emit_cfi)
+   add_cfi_restore (regno);
   update_row_reg_save (cur_row, regno, NULL);
 }
   else
@@ -1369,7 +1370,8 @@ dwarf2out_frame_debug_cfa_restore (rtx reg)
  reg = XVECEXP (span, 0, par_index);
  gcc_assert (REG_P (reg));
  unsigned int regno = dwf_regno (reg);
- add_cfi_restore (regno);
+ if (emit_cfi)
+   add_cfi_restore (regno);
  update_row_reg_save (cur_row, regno, NULL);
}
 }
@@ -2155,6 +2157,7 @@ dwarf2out_frame_debug (rtx_insn *insn)
break;

   case REG_CFA_RESTORE:
+  case REG_CFA_NO_RESTORE:
n = XEXP (note, 0);
if (n == NULL)
  {
@@ -2163,7 +2166,7 @@ dwarf2out_frame_debug (rtx_insn *insn)
  n = XVECEXP (n, 0, 0);
n = XEXP (n,