[Bug middle-end/78098] error: interrupt service routine can't be called directly

2019-11-14 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|7.5 |---

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2018-12-06 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|7.4 |7.5

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2018-01-25 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|7.3 |7.4

--- Comment #18 from Richard Biener  ---
GCC 7.3 is being released, adjusting target milestone.

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2017-08-16 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|7.2 |7.3

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2017-08-14 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|7.3 |---

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2017-08-14 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|7.2 7.2 |7.3 7.3

--- Comment #18 from Richard Biener  ---
GCC 7.2 is being released, adjusting target milestone.

--- Comment #19 from Richard Biener  ---
GCC 7.2 is being released, adjusting target milestone.

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2017-08-14 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|7.2 7.2 |7.3 7.3

--- Comment #18 from Richard Biener  ---
GCC 7.2 is being released, adjusting target milestone.

--- Comment #19 from Richard Biener  ---
GCC 7.2 is being released, adjusting target milestone.

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2017-05-02 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

Jakub Jelinek  changed:

   What|Removed |Added

   Target Milestone|7.0 |7.2

--- Comment #17 from Jakub Jelinek  ---
GCC 7.1 has been released.

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2016-10-27 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

--- Comment #16 from H.J. Lu  ---
(In reply to Martin Liška from comment #15)
> > 
> > Not with interrupt handler which needs different epilogue and prologue.
> 
> I see, however I'm not sure it's known information when IPA ICF is running.
> Or am I wrong?

The information is available.  But I don't know if ICF should be concerned.
We can disable ICF for interrupt handler or use it as a feature to detect
code duplication for interrupt handler, which I submitted a patch for:

https://gcc.gnu.org/ml/gcc-patches/2016-10/msg02177.html

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2016-10-27 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

--- Comment #15 from Martin Liška  ---
> 
> Not with interrupt handler which needs different epilogue and prologue.

I see, however I'm not sure it's known information when IPA ICF is running.
Or am I wrong?

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2016-10-27 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

--- Comment #14 from H.J. Lu  ---
(In reply to Martin Liška from comment #13)
> (In reply to H.J. Lu from comment #12)
> > (In reply to Martin Liška from comment #10)
> > > (In reply to H.J. Lu from comment #9)
> > > > (In reply to Richard Biener from comment #6)
> > > > > Why would we be not able to tailcall in an interupt handler?
> > > > 
> > > > We need to verify that the only instruction in an interrupt handler
> > > > is a tail call to another interrupt handler.  On the other hand,
> > > > this interrupt handler isn't really needed at all.
> > > 
> > > That can be vefief by fact that the symbol should have only one call (tail
> > > call) and set node->icf_merged == true.
> > 
> > Another issue with ICF tail call:
> > 
> > ;; Function foo1 (foo1, funcdef_no=3, decl_uid=1443, cgraph_uid=0,
> > symbol_order=0)
> > 
> > foo1 (void * p)
> > {
> > ;;   basic block 2, loop depth 0
> > ;;pred:   ENTRY
> >   foo2 (p_2(D)); [tail call]
> >   ^^^  This isn't the same as sibcall.
> >   return;
> >   ^^  Here is a return statement.
> > ;;succ:   EXIT
> > 
> > }
> 
> If I remember correctly, this is gimple representation of the tail-call. If
> you look at the generated binary, you'll see really just the jump
> instruction:
> 
> foo2:
> .LFB1:
>   .cfi_startproc
>   movl$4276093056, %eax
>   movl$0, (%rax)
>   ret
>   .cfi_endproc
> .LFE1:
>   .size   foo2, .-foo2
>   .p2align 4,,15
>   .globl  foo1
>   .type   foo1, @function
> foo1:
> .LFB3:
>   .cfi_startproc
>   jmp foo2
>   .cfi_endproc

Not with interrupt handler which needs different epilogue and prologue.

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2016-10-27 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

--- Comment #13 from Martin Liška  ---
(In reply to H.J. Lu from comment #12)
> (In reply to Martin Liška from comment #10)
> > (In reply to H.J. Lu from comment #9)
> > > (In reply to Richard Biener from comment #6)
> > > > Why would we be not able to tailcall in an interupt handler?
> > > 
> > > We need to verify that the only instruction in an interrupt handler
> > > is a tail call to another interrupt handler.  On the other hand,
> > > this interrupt handler isn't really needed at all.
> > 
> > That can be vefief by fact that the symbol should have only one call (tail
> > call) and set node->icf_merged == true.
> 
> Another issue with ICF tail call:
> 
> ;; Function foo1 (foo1, funcdef_no=3, decl_uid=1443, cgraph_uid=0,
> symbol_order=0)
> 
> foo1 (void * p)
> {
> ;;   basic block 2, loop depth 0
> ;;pred:   ENTRY
>   foo2 (p_2(D)); [tail call]
>   ^^^  This isn't the same as sibcall.
>   return;
>   ^^  Here is a return statement.
> ;;succ:   EXIT
> 
> }

If I remember correctly, this is gimple representation of the tail-call. If you
look at the generated binary, you'll see really just the jump instruction:

foo2:
.LFB1:
.cfi_startproc
movl$4276093056, %eax
movl$0, (%rax)
ret
.cfi_endproc
.LFE1:
.size   foo2, .-foo2
.p2align 4,,15
.globl  foo1
.type   foo1, @function
foo1:
.LFB3:
.cfi_startproc
jmp foo2
.cfi_endproc

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2016-10-26 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

--- Comment #12 from H.J. Lu  ---
(In reply to Martin Liška from comment #10)
> (In reply to H.J. Lu from comment #9)
> > (In reply to Richard Biener from comment #6)
> > > Why would we be not able to tailcall in an interupt handler?
> > 
> > We need to verify that the only instruction in an interrupt handler
> > is a tail call to another interrupt handler.  On the other hand,
> > this interrupt handler isn't really needed at all.
> 
> That can be vefief by fact that the symbol should have only one call (tail
> call) and set node->icf_merged == true.

Another issue with ICF tail call:

;; Function foo1 (foo1, funcdef_no=3, decl_uid=1443, cgraph_uid=0,
symbol_order=0)

foo1 (void * p)
{
;;   basic block 2, loop depth 0
;;pred:   ENTRY
  foo2 (p_2(D)); [tail call]
  ^^^  This isn't the same as sibcall.
  return;
  ^^  Here is a return statement.
;;succ:   EXIT

}

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2016-10-25 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

--- Comment #11 from H.J. Lu  ---
(In reply to Martin Liška from comment #10)
> (In reply to H.J. Lu from comment #9)
> > (In reply to Richard Biener from comment #6)
> > > Why would we be not able to tailcall in an interupt handler?
> > 
> > We need to verify that the only instruction in an interrupt handler
> > is a tail call to another interrupt handler.  On the other hand,
> > this interrupt handler isn't really needed at all.
> 
> That can be vefief by fact that the symbol should have only one call (tail
> call) and set node->icf_merged == true.

My current change:

@ -28014,7 +28026,19 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx callarg1,
   if (fndecl
 && (lookup_attribute ("interrupt",
TYPE_ATTRIBUTES (TREE_TYPE (fndecl)
-  error ("interrupt service routine can't be called directly");
+  {
+if (lookup_attribute ("interrupt",
+   TYPE_ATTRIBUTES (TREE_TYPE (cfun->decl
+  {
+error ("interrupt service routine %q+D can't be called directly",
+  fndecl);
+inform (input_location,
+   "is interrupt service routine %q+D equivalent to %q+D?",
+   fndecl, cfun->decl);
+  }
+else
+  error ("interrupt service routine can't be called directly");
+  }
 }
   else
 fndecl = NULL_TREE;

gives

/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -Os -m32 -mno-sse -mno-mmx
-mno-80387 -S -o foo1.s foo1.i
foo1.i: In function ‘foo1’:
foo1.i:10:33: error: interrupt service routine ‘foo2’ can't be called directly
 __attribute__((interrupt)) void foo2 (void *p)
 ^~~~
foo1.i:4:6: note: is interrupt service routine ‘foo2’ equivalent to ‘foo1’?
 void foo1 (void *p)
  ^~~~
Makefile:34: recipe for target 'foo1.s' failed
make: *** [foo1.s] Error 1
[hjl@gnu-6 pr78098]$ 

Since foo1 == foo2, there is no reason for foo2 at all.  It reduces
the code size, which is very important in embedded environment.

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2016-10-25 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

--- Comment #10 from Martin Liška  ---
(In reply to H.J. Lu from comment #9)
> (In reply to Richard Biener from comment #6)
> > Why would we be not able to tailcall in an interupt handler?
> 
> We need to verify that the only instruction in an interrupt handler
> is a tail call to another interrupt handler.  On the other hand,
> this interrupt handler isn't really needed at all.

That can be vefief by fact that the symbol should have only one call (tail
call) and set node->icf_merged == true.

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2016-10-25 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

--- Comment #9 from H.J. Lu  ---
(In reply to Richard Biener from comment #6)
> Why would we be not able to tailcall in an interupt handler?

We need to verify that the only instruction in an interrupt handler
is a tail call to another interrupt handler.  On the other hand,
this interrupt handler isn't really needed at all.

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2016-10-25 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

--- Comment #8 from H.J. Lu  ---
(In reply to Martin Liška from comment #7)
> > Can ICF turn foo1 into a tail call to foo2 when foo2 has an interrupt
> > attribute?
> 
> Problem here is that comp_type_attributes returns 1 as
> 
> $18 = {name = 0x19d357b "interrupt", min_length = 0, max_length = 0,
> decl_required = false, type_required = true, function_type_required = true,
> handler = 0x1195b30  bool*)>, affects_type_identity = false}
> 
> has set affects_type_identity == false. I would expect to have the flag set
> to true? Is it bug?

I have a patch for them.

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2016-10-25 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

--- Comment #7 from Martin Liška  ---
> Can ICF turn foo1 into a tail call to foo2 when foo2 has an interrupt
> attribute?

Problem here is that comp_type_attributes returns 1 as

$18 = {name = 0x19d357b "interrupt", min_length = 0, max_length = 0,
decl_required = false, type_required = true, function_type_required = true,
handler = 0x1195b30 , affects_type_identity = false}

has set affects_type_identity == false. I would expect to have the flag set to
true? Is it bug?

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2016-10-25 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

--- Comment #6 from Richard Biener  ---
Why would we be not able to tailcall in an interupt handler?

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2016-10-24 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

--- Comment #5 from H.J. Lu  ---
(In reply to Martin Liška from comment #4)
> Hello H.J.
> As interrupt handler attribute is very specific and rare attribute, I'm
> suggesting to basically skip all functions in IPA ICF analysis that have
> such attribute.
> 
> Does it work for you?

I'd like to keep it as a "feature" to detect code duplication in
interrupt handler, like

[hjl@gnu-6 pr78098]$ /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -Os -m32 -mno-sse -mno-mmx
-mno-80387 -S -o foo1.s foo1.i
foo1.i: In function ‘foo1’:
foo1.i:10:33: error: interrupt service routine ‘foo2’ can't be called directly
 __attribute__((interrupt)) void foo2 (void *p)
 ^~~~
foo1.i:10:33: note: is interrupt service routine ‘foo1’ identical to ‘foo2’?
[hjl@gnu-6 pr78098]$

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2016-10-24 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

Martin Liška  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2016-10-24
   Target Milestone|--- |7.0
 Ever confirmed|0   |1

--- Comment #4 from Martin Liška  ---
Hello H.J.
As interrupt handler attribute is very specific and rare attribute, I'm
suggesting to basically skip all functions in IPA ICF analysis that have such
attribute.

Does it work for you?

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2016-10-24 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

--- Comment #3 from H.J. Lu  ---
Another problem:

[hjl@gnu-6 pr78098]$ cat foo2.i 
void bar (int);

void foo1 (void *p)
{
  bar (0);
  *((int *)0xFEE00080) = 0;
}

__attribute__((interrupt)) void foo2 (void *p)
{
  bar (0);
  *((int *)0xFEE00080) = 0;
}
[hjl@gnu-6 pr78098]$ make foo2.s
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -Os -DQM_LAKEMONT  -m32 -miamcu
-mno-sse -mno-mmx -mno-80387 -S -o foo2.s foo2.i
foo2.i: In function ‘foo1’:
foo2.i:3:6: error: interrupt service routine can't be called directly
 void foo1 (void *p)
  ^~~~
Makefile:33: recipe for target 'foo2.s' failed
make: *** [foo2.s] Error 1
[hjl@gnu-6 pr78098]$ 

Can ICF turn foo1 into a tail call to foo2 when foo2 has an interrupt
attribute?

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2016-10-24 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

--- Comment #2 from H.J. Lu  ---
GCC correctly identified that foo1 == foo2 and generate a tail call.
But we don't want tail call in interrupt handler.  On the other hand,
there is no need to have 2 identical copies of an interrupt handler.
There should be only one interrupt handler or they should be different.

This patch

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index eef6d7b..be40ad9 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -28014,7 +28014,8 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx callarg1,
   if (fndecl
 && (lookup_attribute ("interrupt",
TYPE_ATTRIBUTES (TREE_TYPE (fndecl)
-  error ("interrupt service routine can't be called directly");
+  error ("interrupt service routine %q+D can't be called directly",
+ fndecl);
 }
   else
 fndecl = NULL_TREE;

changes the error message to

foo.i: In function ‘foo1’:
foo.i:9:33: error: interrupt service routine ‘foo2’ can't be called directly
 __attribute__((interrupt)) void foo2 (void *p)

to indicate that foo2 is called from foo1.

[Bug middle-end/78098] error: interrupt service routine can't be called directly

2016-10-24 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78098

H.J. Lu  changed:

   What|Removed |Added

 CC||marxin at gcc dot gnu.org
  Component|target  |middle-end

--- Comment #1 from H.J. Lu  ---
It is generated by IPA-ICF.