public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/4999: asm code with concatenated content fails in template class member functions
@ 2001-12-03 16:54 rodrigc
  0 siblings, 0 replies; 6+ messages in thread
From: rodrigc @ 2001-12-03 16:54 UTC (permalink / raw)
  To: gcc-bugs, gcc-gnats, gcc-prs, nobody, sethml

Synopsis: asm code with concatenated content fails in template class member functions

State-Changed-From-To: open->feedback
State-Changed-By: rodrigc
State-Changed-When: Mon Dec  3 16:54:57 2001
State-Changed-Why:
    I don't think you have valid asm.  Here is what gcc 3.0.3 (prerelease)
    says when I try to compile your code:
    
    bug1.cc: In static member function `static int test<X>::foo(int*, int*) [with X
       = int]':
    bug1.cc:21:   instantiated from here
    bug1.cc:4: invalid `asm': operand number missing after %-letter
    bug1.cc:4: invalid `asm': operand number missing after %-letter
    bug1.cc:5: invalid `asm': operand number missing after %-letter
    bug1.cc:5: invalid `asm': operand number missing after %-letter
    bug1.cc:6: invalid `asm': operand number missing after %-letter
    bug1.cc:6: invalid `asm': operand number missing after %-letter
    bug1.cc:8: invalid `asm': operand number missing after %-letter
    bug1.cc:8: invalid `asm': operand number missing after %-letter
    bug1.cc:9: invalid `asm': operand number missing after %-letter
    bug1.cc:9: invalid `asm': operand number missing after %-letter
    bug1.cc:10: invalid `asm': operand number missing after %-letter
    bug1.cc:10: invalid `asm': operand number missing after %-letter
    bug1.cc:11: invalid `asm': operand number missing after %-letter
    bug1.cc:11: invalid `asm': operand number missing after %-letter
    bug1.cc:12: invalid `asm': operand number missing after %-letter
    bug1.cc:12: invalid `asm': operand number missing after %-letter
    bug1.cc:13: invalid `asm': operand number missing after %-letter
    bug1.cc:13: invalid `asm': operand number missing after %-letter
    bug1.cc:14: invalid `asm': operand number missing after %-letter
    bug1.cc:14: invalid `asm': operand number missing after %-letter
    bug1.cc:15: invalid `asm': operand number missing after %-letter
    bug1.cc:15: invalid `asm': operand number missing after %-letter
    bug1.cc:16: invalid `asm': operand number missing after %-letter
    bug1.cc:16: invalid `asm': operand number missing after %-letter
    
    
    You might want to contact the libmmx maintainer about this.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4999&database=gcc


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: c++/4999: asm code with concatenated content fails in template class member functions
@ 2001-12-04  0:06 rodrigc
  0 siblings, 0 replies; 6+ messages in thread
From: rodrigc @ 2001-12-04  0:06 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/4999; it has been noted by GNATS.

From: rodrigc@gcc.gnu.org
To: gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org,
  nobody@gcc.gnu.org, sethml@ofb.net
Cc:  
Subject: Re: c++/4999: asm code with concatenated content fails in template class member functions
Date: 4 Dec 2001 08:02:49 -0000

 Synopsis: asm code with concatenated content fails in template class member functions
 
 State-Changed-From-To: feedback->closed
 State-Changed-By: rodrigc
 State-Changed-When: Tue Dec  4 00:02:49 2001
 State-Changed-Why:
     gcc 2.95.3 was the latest FSF stable release of the gcc 2.95 tree.  It cannot compile the MMX code you provided in your latest testcase without FSF unsupported patches to the compiler.  
     
     gcc 2.95.4 is not an FSF release, but is a release from
     Debian.  I do not know if this release has MMX patches in
     
     gcc 2.95 is currently a maintenance release, and most
     active FSF gcc development and bugfixing is going on
     in the gcc 3.x series.
     
     gcc 3.0, which has MMX support integrated, can successfully
     compile your testcase.
     it or not.
     
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4999&database=gcc


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: c++/4999: asm code with concatenated content fails in template class member functions
@ 2001-12-04  0:02 rodrigc
  0 siblings, 0 replies; 6+ messages in thread
From: rodrigc @ 2001-12-04  0:02 UTC (permalink / raw)
  To: gcc-bugs, gcc-gnats, gcc-prs, nobody, sethml

Synopsis: asm code with concatenated content fails in template class member functions

State-Changed-From-To: feedback->closed
State-Changed-By: rodrigc
State-Changed-When: Tue Dec  4 00:02:49 2001
State-Changed-Why:
    gcc 2.95.3 was the latest FSF stable release of the gcc 2.95 tree.  It cannot compile the MMX code you provided in your latest testcase without FSF unsupported patches to the compiler.  
    
    gcc 2.95.4 is not an FSF release, but is a release from
    Debian.  I do not know if this release has MMX patches in
    
    gcc 2.95 is currently a maintenance release, and most
    active FSF gcc development and bugfixing is going on
    in the gcc 3.x series.
    
    gcc 3.0, which has MMX support integrated, can successfully
    compile your testcase.
    it or not.
    

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4999&database=gcc


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: c++/4999: asm code with concatenated content fails in template class member functions
@ 2001-12-03 21:36 sethml
  0 siblings, 0 replies; 6+ messages in thread
From: sethml @ 2001-12-03 21:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/4999; it has been noted by GNATS.

From: sethml@ofb.net
To: rodrigc@gcc.gnu.org
Cc: gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org,
	nobody@gcc.gnu.org, sethml@ofb.net
Subject: Re: c++/4999: asm code with concatenated content fails in template class member functions 
Date: Mon, 03 Dec 2001 21:29:17 -0800

 >     I don't think you have valid asm.  Here is what gcc 3.0.3 (prerelease)
 >     says when I try to compile your code:
 
 Uh, I filed the bug report against 2.95.4, not 3.0.  It looks like
 gcc-3.0 became more strict about stray '%'s in code.  If I fix the
 '%'s, the problem remains.  Note that it is only a problem with 2.95 -
 apparently it's been fixed in 3.0.  I'm making the assumption that
 2.95 is still being actively maintained.
 
 Here's a version that compiles under gcc-3.0, but breaks gcc-2.95.4:
 
   template <class X> struct test {
     static int foo(int *b1, int *b2) {
       __asm__ ("movq" " %0, %%" "mm2" : : "m" (*(long long *)b1));
       __asm__ ("movq" " %%" "mm2" ", %%" "mm3")  ;
       __asm__ ("punpckhbw" " %%" "mm0" ", %%" "mm2")  ;
       __asm__ ("punpckhbw" " %%" "mm0" ", %%" "mm3")  ;
       __asm__ ("movq" " %0, %%" "mm4" : : "m" (*(long long *)b2));
       __asm__ ("movq" " %%" "mm4" ", %%" "mm5")  ;
       __asm__ ("punpckhbw" " %%" "mm0" ", %%" "mm4")  ;
       __asm__ ("punpckhbw" " %%" "mm0" ", %%" "mm5")  ;
       __asm__ ("psubsw" " %%" "mm4" ", %%" "mm2")  ;
       __asm__ ("psubsw" " %%" "mm5" ", %%" "mm3")  ;
       __asm__ ("pmaddwd" " %%" "mm2" ", %%" "mm2")  ;
       __asm__ ("pmaddwd" " %%" "mm3" ", %%" "mm3")  ;
       __asm__ ("paddd" " %%" "mm2" ", %%" "mm1")  ;
       __asm__ ("paddd" " %%" "mm3" ", %%" "mm1")  ;
     }
   };
 
   int main(int argc) {
     test<int>::foo(&argc, &argc);
   }
 
 Seth


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: c++/4999: asm code with concatenated content fails in template class member functions
@ 2001-12-03 16:56 rodrigc
  0 siblings, 0 replies; 6+ messages in thread
From: rodrigc @ 2001-12-03 16:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/4999; it has been noted by GNATS.

From: rodrigc@gcc.gnu.org
To: gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org,
  nobody@gcc.gnu.org, sethml@ofb.net
Cc:  
Subject: Re: c++/4999: asm code with concatenated content fails in template class member functions
Date: 4 Dec 2001 00:54:57 -0000

 Synopsis: asm code with concatenated content fails in template class member functions
 
 State-Changed-From-To: open->feedback
 State-Changed-By: rodrigc
 State-Changed-When: Mon Dec  3 16:54:57 2001
 State-Changed-Why:
     I don't think you have valid asm.  Here is what gcc 3.0.3 (prerelease)
     says when I try to compile your code:
     
     bug1.cc: In static member function `static int test<X>::foo(int*, int*) [with X
        = int]':
     bug1.cc:21:   instantiated from here
     bug1.cc:4: invalid `asm': operand number missing after %-letter
     bug1.cc:4: invalid `asm': operand number missing after %-letter
     bug1.cc:5: invalid `asm': operand number missing after %-letter
     bug1.cc:5: invalid `asm': operand number missing after %-letter
     bug1.cc:6: invalid `asm': operand number missing after %-letter
     bug1.cc:6: invalid `asm': operand number missing after %-letter
     bug1.cc:8: invalid `asm': operand number missing after %-letter
     bug1.cc:8: invalid `asm': operand number missing after %-letter
     bug1.cc:9: invalid `asm': operand number missing after %-letter
     bug1.cc:9: invalid `asm': operand number missing after %-letter
     bug1.cc:10: invalid `asm': operand number missing after %-letter
     bug1.cc:10: invalid `asm': operand number missing after %-letter
     bug1.cc:11: invalid `asm': operand number missing after %-letter
     bug1.cc:11: invalid `asm': operand number missing after %-letter
     bug1.cc:12: invalid `asm': operand number missing after %-letter
     bug1.cc:12: invalid `asm': operand number missing after %-letter
     bug1.cc:13: invalid `asm': operand number missing after %-letter
     bug1.cc:13: invalid `asm': operand number missing after %-letter
     bug1.cc:14: invalid `asm': operand number missing after %-letter
     bug1.cc:14: invalid `asm': operand number missing after %-letter
     bug1.cc:15: invalid `asm': operand number missing after %-letter
     bug1.cc:15: invalid `asm': operand number missing after %-letter
     bug1.cc:16: invalid `asm': operand number missing after %-letter
     bug1.cc:16: invalid `asm': operand number missing after %-letter
     
     
     You might want to contact the libmmx maintainer about this.
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4999&database=gcc


^ permalink raw reply	[flat|nested] 6+ messages in thread

* c++/4999: asm code with concatenated content fails in template class member functions
@ 2001-12-03 16:16 sethml
  0 siblings, 0 replies; 6+ messages in thread
From: sethml @ 2001-12-03 16:16 UTC (permalink / raw)
  To: gcc-gnats

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 5753 bytes --]


>Number:         4999
>Category:       c++
>Synopsis:       asm code with concatenated content fails in template class member functions
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 03 16:16:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     sethml@ofb.net
>Release:        2.95.4
>Organization:
>Environment:
Debian unstable (sid) i386, Linux 2.2.17
>Description:
It appears that using literal string concatenation within asm code can cause corruption of the assembly generated by gcc - it contains random junk (including characters with the high bit set) rather than the assembly, and gas gives up.  Note that literal string concatenation within asm code is used extensively by libmmx:
  http://min.ecn.purdue.edu/~rfisher/Research/Libmmx/libmmx.html

Here's a chunk of code that demonstrates the problem:

  template <class X> struct test {
    static int foo(int *b1, int *b2) {
      __asm__ ("movq" " %0, %%" "mm2" : : "m" (*(long long *)b1)); 
      __asm__ ("movq" " %" "mm2" ", %" "mm3")  ; 
      __asm__ ("punpckhbw" " %" "mm0" ", %" "mm2")  ; 
      __asm__ ("punpckhbw" " %" "mm0" ", %" "mm3")  ; 
      __asm__ ("movq" " %0, %%" "mm4" : : "m" (*(long long *)b2)); 
      __asm__ ("movq" " %" "mm4" ", %" "mm5")  ; 
      __asm__ ("punpckhbw" " %" "mm0" ", %" "mm4")  ; 
      __asm__ ("punpckhbw" " %" "mm0" ", %" "mm5")  ; 
      __asm__ ("psubsw" " %" "mm4" ", %" "mm2")  ; 
      __asm__ ("psubsw" " %" "mm5" ", %" "mm3")  ; 
      __asm__ ("pmaddwd" " %" "mm2" ", %" "mm2")  ; 
      __asm__ ("pmaddwd" " %" "mm3" ", %" "mm3")  ; 
      __asm__ ("paddd" " %" "mm2" ", %" "mm1")  ; 
      __asm__ ("paddd" " %" "mm3" ", %" "mm1")  ; 
    }
  }; 
  
  int main(int argc) {
    test<int>::foo(&argc, &argc);
  }

Here's what happens when attempting to compile it, for me:

  % g++ -v --save-temps bug1.cc
  Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
  gcc version 2.95.4 20011006 (Debian prerelease)
   /usr/lib/gcc-lib/i386-linux/2.95.4/cpp0 -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ bug1.cc bug1.ii
  GNU CPP version 2.95.4 20011006 (Debian prerelease) (i386 Linux/ELF)
  #include "..." search starts here:
  #include <...> search starts here:
   /usr/lib/gcc-lib/i386-linux/2.95.4/../../../../include/g++-3
   /usr/local/include
   /usr/lib/gcc-lib/i386-linux/2.95.4/include
   /usr/include
  End of search list.
  The following default directories have been omitted from the search path:
   /usr/lib/gcc-lib/i386-linux/2.95.4/../../../../i386-linux/include
  End of omitted list.
   /usr/lib/gcc-lib/i386-linux/2.95.4/cc1plus bug1.ii -quiet -dumpbase bug1.cc -version -o bug1.s
  GNU C++ version 2.95.4 20011006 (Debian prerelease) (i386-linux) compiled by GNU C version 2.95.4 20011006 (Debian prerelease).
   as -V -Qy -o bug1.o bug1.s
  GNU assembler version 2.11.92.0.10 (i386-linux) using BFD version 2.11.92.0.10 20011021 Debian/GNU Linux
  bug1.s: Assembler messages:
  bug1.s:46: Error: invalid character (0xffffffe7) in mnemonic
  bug1.s:47: Error: invalid character (0xffffffa0) in mnemonic
  bug1.s:48: Warning: rest of line ignored; first ignored character valued 0xb
  bug1.s:49: Warning: rest of line ignored; first ignored character is `6'
  bug1.s:50: Error: invalid character '.' in mnemonic
  bug1.s:57: Error: invalid character '>' in mnemonic

I've attached an archive with the intermediate .s file, which contains such exciting lines of assembly as "pç8ç&", "e.t.foo__t4test1ZiPiT1", and "int>::foo(int *, int *)".  Clearly there's some random memory corruption going on.

See also bug report titled "volatile asm code fails in template class member functions".
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/x-gzip-compressed; name="bug1.tgz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="bug1.tgz"

H4sIAJEUDDwAA+1X/W7iR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qOof/XvXofVN7/fH9fPnbc/4jN2Or+RzCT9z/OeHP/+xCUiSgJ3Uyg
F37opin64SVKs9ncz5DsQuhXHcG7mwW+6omrFumRokl6tKMWIeQ4bho5Dmob0ON/NpCBDmXnPQQO
Wq2BBvAxIgO1j9vhNJ4g9TjueKTTeb7NwFLXMAueGR2ENpevun2pgys69Ak6tX5q8uLb86K78uIV
f/YTYuRP0Kn3o+5F9YHVg7ehYO+sUAR36PtxfU3rXWxqsJ0+QGGLB/IP1rO69Q/6w3Ndlxtd3s3V
1ndnEz/f8vIH8qK8Oh7JGROpASr/8HG0i/L8D4J9+dh5/ttk8/8/t1lz/n8IOkAElX/+m27QdIOm
G3y63aChhhpqqKGGGmqooYYaaqihhhr6P9LfzaY9LgAoAAA=


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-12-04  8:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-03 16:54 c++/4999: asm code with concatenated content fails in template class member functions rodrigc
  -- strict thread matches above, loose matches on Subject: below --
2001-12-04  0:06 rodrigc
2001-12-04  0:02 rodrigc
2001-12-03 21:36 sethml
2001-12-03 16:56 rodrigc
2001-12-03 16:16 sethml

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).