[Bug c++/33661] template methods forget explicit local register asm vars

2021-09-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |8.5

[Bug c++/33661] template methods forget explicit local register asm vars

2021-04-22 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661

Jakub Jelinek  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||jakub at gcc dot gnu.org
 Resolution|--- |FIXED

--- Comment #23 from Jakub Jelinek  ---
Fixed.

[Bug c++/33661] template methods forget explicit local register asm vars

2021-04-22 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661

--- Comment #22 from CVS Commits  ---
The releases/gcc-8 branch has been updated by Jakub Jelinek
:

https://gcc.gnu.org/g:712ffc0ad150aadfa5b91f493075e88fd050189f

commit r8-10878-g712ffc0ad150aadfa5b91f493075e88fd050189f
Author: Jakub Jelinek 
Date:   Thu Jan 28 16:13:11 2021 +0100

c++: Fix up handling of register ... asm ("...") vars in templates
[PR33661, PR98847]

As the testcase shows, for vars appearing in templates, we don't attach
the asm spec string to the pattern decls, nor pass it back to
cp_finish_decl
during instantiation.

The following patch does that.

2021-01-28  Jakub Jelinek  

PR c++/33661
PR c++/98847
* decl.c (cp_finish_decl): For register vars with asmspec in
templates
call set_user_assembler_name and set DECL_HARD_REGISTER.
* pt.c (tsubst_expr): When instantiating DECL_HARD_REGISTER vars,
pass asmspec_tree to cp_finish_decl.

* g++.dg/opt/pr98847.C: New test.

(cherry picked from commit cf93f94b3498f3925895fb0bbfd4b64232b9987a)

[Bug c++/33661] template methods forget explicit local register asm vars

2021-04-20 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661

--- Comment #21 from CVS Commits  ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
:

https://gcc.gnu.org/g:ef5db37cc4e80b229502bea7d6e2daa95ad6f805

commit r9-9412-gef5db37cc4e80b229502bea7d6e2daa95ad6f805
Author: Jakub Jelinek 
Date:   Thu Jan 28 16:13:11 2021 +0100

c++: Fix up handling of register ... asm ("...") vars in templates
[PR33661, PR98847]

As the testcase shows, for vars appearing in templates, we don't attach
the asm spec string to the pattern decls, nor pass it back to
cp_finish_decl
during instantiation.

The following patch does that.

2021-01-28  Jakub Jelinek  

PR c++/33661
PR c++/98847
* decl.c (cp_finish_decl): For register vars with asmspec in
templates
call set_user_assembler_name and set DECL_HARD_REGISTER.
* pt.c (tsubst_expr): When instantiating DECL_HARD_REGISTER vars,
pass asmspec_tree to cp_finish_decl.

* g++.target/i386/pr98847.C: New test.

(cherry picked from commit cf93f94b3498f3925895fb0bbfd4b64232b9987a)

[Bug c++/33661] template methods forget explicit local register asm vars

2021-01-30 Thread fw at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661

Florian Weimer  changed:

   What|Removed |Added

 CC||nate at verse dot com

--- Comment #20 from Florian Weimer  ---
*** Bug 58118 has been marked as a duplicate of this bug. ***

[Bug c++/33661] template methods forget explicit local register asm vars

2021-01-29 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661

--- Comment #19 from CVS Commits  ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
:

https://gcc.gnu.org/g:cf93f94b3498f3925895fb0bbfd4b64232b9987a

commit r10-9323-gcf93f94b3498f3925895fb0bbfd4b64232b9987a
Author: Jakub Jelinek 
Date:   Thu Jan 28 16:13:11 2021 +0100

c++: Fix up handling of register ... asm ("...") vars in templates
[PR33661, PR98847]

As the testcase shows, for vars appearing in templates, we don't attach
the asm spec string to the pattern decls, nor pass it back to
cp_finish_decl
during instantiation.

The following patch does that.

2021-01-28  Jakub Jelinek  

PR c++/33661
PR c++/98847
* decl.c (cp_finish_decl): For register vars with asmspec in
templates
call set_user_assembler_name and set DECL_HARD_REGISTER.
* pt.c (tsubst_expr): When instantiating DECL_HARD_REGISTER vars,
pass asmspec_tree to cp_finish_decl.

* g++.target/i386/pr98847.C: New test.

[Bug c++/33661] template methods forget explicit local register asm vars

2021-01-28 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661

--- Comment #18 from CVS Commits  ---
The master branch has been updated by Jakub Jelinek :

https://gcc.gnu.org/g:6bb207b468da36d9d99c63409dc4098514759c90

commit r11-6958-g6bb207b468da36d9d99c63409dc4098514759c90
Author: Jakub Jelinek 
Date:   Thu Jan 28 16:13:11 2021 +0100

c++: Fix up handling of register ... asm ("...") vars in templates
[PR33661, PR98847]

As the testcase shows, for vars appearing in templates, we don't attach
the asm spec string to the pattern decls, nor pass it back to
cp_finish_decl
during instantiation.

The following patch does that.

2021-01-28  Jakub Jelinek  

PR c++/33661
PR c++/98847
* decl.c (cp_finish_decl): For register vars with asmspec in
templates
call set_user_assembler_name and set DECL_HARD_REGISTER.
* pt.c (tsubst_expr): When instantiating DECL_HARD_REGISTER vars,
pass asmspec_tree to cp_finish_decl.

* g++.target/i386/pr98847.C: New test.

[Bug c++/33661] template methods forget explicit local register asm vars

2020-04-11 Thread mp8191mp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661

Martin Papik  changed:

   What|Removed |Added

 CC||mp8191mp at gmail dot com

--- Comment #17 from Martin Papik  ---

Hello, I found a bug, which I think is a duplicate of this one, but am not 100%
sure.

Below is a minimal piece of code which triggers the bug. All versions of gcc
seem to be affected, as seen on compiler explorer,
https://godbolt.org/z/jFMj8b, which also shows a difference in gimple, the
templated version is missing the explicit naming attributes.

Is this the same bug? If so, is there some technical reason why a clear
miscompilation persists for as long as it seems to? What I mean is this, if a
bug like this persists for this long, it could be taken to mean that the bug is
too big for a casual volunteer. Would that be the case? Can someone familiar
with the code base tell me what I'd need to know to fix this, e.g. what's wrong
with the patch, is it better to fix the patch or start from scratch.


$ cat bug.cpp
#define DEMONSTRABLY_IDENTICAL  \
long ret;   \
register long r10 __asm__("r10") = (long)a4;\
__asm__ __volatile__ ("syscall" \
: "=a"(ret) \
: "a"(n), "D"(a1), "S"(a2), "d"(a3), "r"(r10)   \
: "rcx", "r11", "memory"\
);
enum class sysnr : long {
// accept4 has enough parameters to require extra registers and trigger
the bug
accept4 = 0x120
};
static __inline long sys_01(long n, long a1, long a2, long a3, long a4)
{
DEMONSTRABLY_IDENTICAL
return ret;
}
template 
RET sys_02(T1 a1, T2 a2, T3 a3, T4 a4) {
constexpr long n = (long) SYS_NR;
DEMONSTRABLY_IDENTICAL
return (RET)ret;
}
void test_01 () {
sys_01( (long)sysnr::accept4, 0xfeed01, 0xfeed02, 0xfeed03, 0xfeed04 );
}
void test_02() {
sys_02( 0xfeed01, 0xfeed02, 0xfeed03, 0xfeed04 );
}
void test_03() {
sys_02( 0xfeed01,
0xfeed02, 0xfeed03, 0xfeed04 );
}

$ g++ -std=c++11 -O1 bug.cpp -c -o bug.c
$ objdump -Cd bug.o 

bug.o: file format elf64-x86-64


Disassembly of section .text:

 :
   0:   41 ba 04 ed fe 00   mov$0xfeed04,%r10d
   6:   b8 20 01 00 00  mov$0x120,%eax
   b:   bf 01 ed fe 00  mov$0xfeed01,%edi
  10:   be 02 ed fe 00  mov$0xfeed02,%esi
  15:   ba 03 ed fe 00  mov$0xfeed03,%edx
  1a:   0f 05   syscall 
  1c:   c3  retq   

001d :
  1d:   b8 20 01 00 00  mov$0x120,%eax
  22:   bf 01 ed fe 00  mov$0xfeed01,%edi
  27:   be 02 ed fe 00  mov$0xfeed02,%esi
  2c:   ba 03 ed fe 00  mov$0xfeed03,%edx
  31:   41 b8 04 ed fe 00   mov$0xfeed04,%r8d
  37:   0f 05   syscall 
  39:   c3  retq   

003a :
  3a:   b8 20 01 00 00  mov$0x120,%eax
  3f:   bf 01 ed fe 00  mov$0xfeed01,%edi
  44:   be 02 ed fe 00  mov$0xfeed02,%esi
  49:   ba 03 ed fe 00  mov$0xfeed03,%edx
  4e:   41 b8 04 ed fe 00   mov$0xfeed04,%r8d
  54:   0f 05   syscall 
  56:   c3  retq

[Bug c++/33661] template methods forget explicit local register asm vars

2019-05-18 Thread gdelugre.gcc at subvert dot technology
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661

--- Comment #16 from Guillaume Delugré  
---
Tested on g++ 9.1.0, the bug is still present. Is there any chance of having
the Andreas' fix pushed upstream?

[Bug c++/33661] template methods forget explicit local register asm vars

2019-04-14 Thread adobriyan at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661

--- Comment #15 from Alexey Dobriyan  ---
I can only reconfirm this bug still exists with 8.2.0 after rediscovering it
independently.

Linux system calls taking 4+ arguments can't be templatized as they require

register T3 _a3 asm("r10") = a3;


But using

"r10" (a3)

in assembly input constraints doesn't work either.

[Bug c++/33661] template methods forget explicit local register asm vars

2017-03-30 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661

Andrew Pinski  changed:

   What|Removed |Added

 CC||gdelugre.gcc at subvert dot 
techno
   ||logy

--- Comment #14 from Andrew Pinski  ---
*** Bug 64951 has been marked as a duplicate of this bug. ***