Bug 39573 - Linking fails on AMD with -march=native and -fopenmp, works with generic x86_64
Summary: Linking fails on AMD with -march=native and -fopenmp, works with generic x86_64
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.3.2
: P3 normal
Target Milestone: 4.4.0
Assignee: Jakub Jelinek
URL:
Keywords: openmp
Depends on:
Blocks:
 
Reported: 2009-03-28 15:42 UTC by F. Beekhof
Modified: 2009-04-28 23:41 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-*-linux-gnu
Build:
Known to work: 4.4.0 4.5.0
Known to fail: 4.3.3
Last reconfirmed: 2009-04-06 08:59:25


Attachments
preprocessed source; with a Makefile! (354.03 KB, application/octet-stream)
2009-04-04 17:45 UTC, F. Beekhof
Details

Note You need to log in before you can comment on or make changes to this bug.
Description F. Beekhof 2009-03-28 15:42:32 UTC
Linking in debugging mode is fine:
$ make CNF=gcc MODE=debug
scons -j 2 CNF=gcc MODE=debug BACKEND=
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o main.o -c -pipe -I. -Wall -g -fopenmp main.cpp
g++ -o tinystr.o -c -pipe -I. -Wall -g -fopenmp tinystr.cpp
g++ -o tinyxml.o -c -pipe -I. -Wall -g -fopenmp tinyxml.cpp
g++ -o tinyxmlerror.o -c -pipe -I. -Wall -g -fopenmp tinyxmlerror.cpp
g++ -o tinyxmlparser.o -c -pipe -I. -Wall -g -fopenmp tinyxmlparser.cpp
g++ -o shapes -g -fopenmp tinystr.o tinyxml.o tinyxmlerror.o tinyxmlparser.o main.o -lcvmlcpp
scons: done building targets.

But in release mode, it's not:
$ make CNF=gcc
scons -j 2 CNF=gcc MODE= BACKEND=
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o main.o -c -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize -DNDEBUG main.cpp
g++ -o tinystr.o -c -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize -DNDEBUG tinystr.cpp
g++ -o tinyxml.o -c -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize -DNDEBUG tinyxml.cpp
g++ -o tinyxmlerror.o -c -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize -DNDEBUG tinyxmlerror.cpp
g++ -o tinyxmlparser.o -c -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize -DNDEBUG tinyxmlparser.cpp
g++ -o shapes -fopenmp tinystr.o tinyxml.o tinyxmlerror.o tinyxmlparser.o main.o -lcvmlcpp
main.o: In function `_ZN7cvmlcppL25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEd.omp_fn.1':
main.cpp:(.text+0x5838): undefined reference to `void cvmlcpp::extractSurfaceFromAdapter<shapes::ShapeSurfaceAdaptor_<double>, double>(shapes::ShapeSurfaceAdaptor_<double> const&, cvmlcpp::Geometry<double>&, double)::C.724'
collect2: ld returned 1 exit status
scons: *** [shapes] Error 1
scons: building terminated because of errors.
make: *** [compile] Error 2

$ g++ -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.2-1ubuntu12' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12) 

Unfortunately, I'm not exactly sure how to complete this report. I have no idea what component does this, so I just guessed. And should I simply attach all source code ?
Comment 1 F. Beekhof 2009-04-03 12:01:46 UTC
I've tried compiling the same code on several machines. Outcome: intel machines are fine, AMD machines exhibit this behaviour.

The second AMD machine has ubuntu 8.04 on it, and a different compiler version:
$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3)

Still, the result is the same:
$ make CNF=gcc
scons -j 2 CNF=gcc MODE= BACKEND= CVMLCPP_PREFIX=/user/l1/beekhof/
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o main.o -c -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize -DNDEBUG -I/user/l1/beekhof//include/ main.cpp
g++ -o tinystr.o -c -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize -DNDEBUG -I/user/l1/beekhof//include/ tinystr.cpp
g++ -o tinyxml.o -c -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize -DNDEBUG -I/user/l1/beekhof//include/ tinyxml.cpp
g++ -o tinyxmlerror.o -c -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize -DNDEBUG -I/user/l1/beekhof//include/ tinyxmlerror.cpp
g++ -o tinyxmlparser.o -c -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize -DNDEBUG -I/user/l1/beekhof//include/ tinyxmlparser.cpp
g++ -o shapes -fopenmp -L/user/l1/beekhof//lib/ tinystr.o tinyxml.o tinyxmlerror.o tinyxmlparser.o main.o -lcvmlcpp -lz -lboost_iostreams
main.o: In function `_ZN7cvmlcpp25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEd.omp_fn.9':
main.cpp:(.text+0x2af2): undefined reference to `_ZN7cvmlcpp25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEd.omp_fn.9::C.497'
collect2: ld returned 1 exit status
scons: *** [shapes] Error 1
scons: building terminated because of errors.
make: *** [compile] Error 2

I'll see if I can make a reduced test-case...

Comment 2 F. Beekhof 2009-04-04 16:57:04 UTC
The problem is the "-march=native" option. If I remove that, all is fine even on AMD machines.

$ make CNF=gcc BACKEND=gsl
scons -j 2 CNF=gcc MODE= BACKEND=gsl CVMLCPP_PREFIX=/user/l1/beekhof/
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o main.o -c -pipe -I. -Wall -O3 -funroll-loops -fopenmp -ftree-vectorize -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ main.cpp
g++ -o tinystr.o -c -pipe -I. -Wall -O3 -funroll-loops -fopenmp -ftree-vectorize -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ tinystr.cpp
g++ -o tinyxml.o -c -pipe -I. -Wall -O3 -funroll-loops -fopenmp -ftree-vectorize -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ tinyxml.cpp
g++ -o tinyxmlerror.o -c -pipe -I. -Wall -O3 -funroll-loops -fopenmp -ftree-vectorize -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ tinyxmlerror.cpp
g++ -o tinyxmlparser.o -c -pipe -I. -Wall -O3 -funroll-loops -fopenmp -ftree-vectorize -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ tinyxmlparser.cpp
g++ -o shapes -fopenmp -DUSE_GSL -L/user/l1/beekhof//lib/ tinystr.o tinyxml.o tinyxmlerror.o tinyxmlparser.o main.o -lcvmlcpp -lz -lboost_iostreams -lgsl -lgslcblas
scons: done building targets.
Comment 3 Steven Bosscher 2009-04-04 17:30:38 UTC
I'm not sure how the -march=native option changes codegen behavior, but the most likely suspect is the vectorizer.  Do things pass with -march=native if you don't vectorize (needs explicit -ftree-vectorize)?
Comment 4 Richard Biener 2009-04-04 17:40:26 UTC
Testcase?
Comment 5 F. Beekhof 2009-04-04 17:45:20 UTC
Created attachment 17586 [details]
preprocessed source; with a Makefile!

Everything fails perfectly:
$ make clean; make
rm -f *.o *~ shapes
gcc -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize   -c -o mainpp.o mainpp.cc
gcc -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize   -c -o tinystrpp.o tinystrpp.cc
gcc -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize   -c -o tinyxmlpp.o tinyxmlpp.cc
gcc -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize   -c -o tinyxmlerrorpp.o tinyxmlerrorpp.cc
gcc -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize   -c -o tinyxmlparserpp.o tinyxmlparserpp.cc
gcc -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize   -c -o SurfaceExtractorpp.o SurfaceExtractorpp.cc
gcc -o shapes -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native -ftree-vectorize -lz -lboost_iostreams -lgsl -lgslcblas mainpp.o tinystrpp.o tinyxmlpp.o tinyxmlerrorpp.o tinyxmlparserpp.o SurfaceExtractorpp.o
mainpp.o: In function `_ZN7cvmlcpp25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEd.omp_fn.8':
mainpp.cc:(.text+0x5641): undefined reference to `void cvmlcpp::extractSurfaceFromAdapter<shapes::ShapeSurfaceAdaptor_<double>, double>(shapes::ShapeSurfaceAdaptor_<double> const&, cvmlcpp::Geometry<double>&, double)::C.907'
collect2: ld returned 1 exit status
make: *** [shapes] Error 1

Oh, and this is the CPU:
$ cat /proc/cpuinfo 
processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 15
model		: 47
model name	: AMD Athlon(tm) 64 Processor 3200+
stepping	: 0
cpu MHz		: 1000.000
cache size	: 512 KB
fpu		: yes
fpu_exception	: yes
cpuid level	: 1
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt lm 3dnowext 3dnow up rep_good nopl pni lahf_lm
bogomips	: 2002.51
TLB size	: 1024 4K pages
clflush size	: 64
cache_alignment	: 64
address sizes	: 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc
Comment 6 Richard Biener 2009-04-04 17:47:13 UTC
So, does it reproduce with -march=athlon64 then?  (or any specific -march?)
Comment 7 F. Beekhof 2009-04-04 18:02:13 UTC
I tried with "-march=native" but without "-ftree-vectorize", it still fails.
I tried with "-march=athlon64" but without "-ftree-vectorize", it still fails.
On an Intel machine, with -march=native and -ftree-vectorize, it is fine.
cpu family	: 6
model		: 15
model name	: Intel(R) Core(TM)2 CPU          6400  @ 2.13GHz
stepping	: 2
Comment 8 Richard Biener 2009-04-04 18:03:59 UTC
Btw, with -O3 the vectorizer is on by default, so you need -fno-tree-vectorize to turn it off.
Comment 9 F. Beekhof 2009-04-04 18:13:28 UTC
Subject: Re:  Linking fails on AMD with -march=native, works
 with generic x86_64

rguenth at gcc dot gnu dot org wrote:
> ------- Comment #8 from rguenth at gcc dot gnu dot org  2009-04-04 18:03 -------
> Btw, with -O3 the vectorizer is on by default, so you need -fno-tree-vectorize
> to turn it off.

(Oh...)
I tried with "-march=native" and "-fno-tree-vectorize", it still fails:

gccbug39573$ make clean; make
rm -f *.o *~ shapes
gcc -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native 
-fno-tree-vectorize   -c -o mainpp.o mainpp.cc
gcc -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native 
-fno-tree-vectorize   -c -o tinystrpp.o tinystrpp.cc
gcc -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native 
-fno-tree-vectorize   -c -o tinyxmlpp.o tinyxmlpp.cc
gcc -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native 
-fno-tree-vectorize   -c -o tinyxmlerrorpp.o tinyxmlerrorpp.cc
gcc -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native 
-fno-tree-vectorize   -c -o tinyxmlparserpp.o tinyxmlparserpp.cc
gcc -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native 
-fno-tree-vectorize   -c -o SurfaceExtractorpp.o SurfaceExtractorpp.cc
gcc -o shapes -pipe -I. -Wall -O3 -funroll-loops -fopenmp -march=native 
-fno-tree-vectorize -lz -lboost_iostreams -lgsl -lgslcblas mainpp.o 
tinystrpp.o tinyxmlpp.o tinyxmlerrorpp.o tinyxmlparserpp.o 
SurfaceExtractorpp.o
mainpp.o: In function 
`_ZN7cvmlcpp25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEd.omp_fn.8':
mainpp.cc:(.text+0x5688): undefined reference to `void 
cvmlcpp::extractSurfaceFromAdapter<shapes::ShapeSurfaceAdaptor_<double>, 
double>(shapes::ShapeSurfaceAdaptor_<double> const&, 
cvmlcpp::Geometry<double>&, double)::C.907'
collect2: ld returned 1 exit status
make: *** [shapes] Error 1

On an
vendor_id	: AuthenticAMD
cpu family	: 15
model		: 47
model name	: AMD Athlon(tm) 64 Processor 3200+
stepping	: 0

As well as on an
processor	: 31
vendor_id	: AuthenticAMD
cpu family	: 16
model		: 2
model name	: Quad-Core AMD Opteron(tm) Processor 8356
stepping	: 3
Comment 10 Steven Bosscher 2009-04-04 18:41:40 UTC
*sigh* I wanted to say in comment #3 that you need explitit -f*no*-tree-vectorize and got it wrong :-)
Comment 11 F. Beekhof 2009-04-04 19:50:10 UTC
No problem. I did a few more tests...

In short, it's the combination of -fopenmp and -march=native that makes fail on AMD64.

Note: To test without openMP you can't use the preprocessed source.

# openmp and march=native --> FAIL
$ make clean; make CNF=gcc BACKEND=gsl
....
g++ -o tinystr.o -c -pipe -I. -Wall -fopenmp -march=native -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ tinystr.cpp
g++ -o main.o -c -pipe -I. -Wall -fopenmp -march=native -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ main.cpp
g++ -o tinyxml.o -c -pipe -I. -Wall -fopenmp -march=native -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ tinyxml.cpp
g++ -o tinyxmlerror.o -c -pipe -I. -Wall -fopenmp -march=native -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ tinyxmlerror.cpp
g++ -o tinyxmlparser.o -c -pipe -I. -Wall -fopenmp -march=native -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ tinyxmlparser.cpp
g++ -o shapes -fopenmp -DUSE_GSL -L/user/l1/beekhof//lib/ tinystr.o tinyxml.o tinyxmlerror.o tinyxmlparser.o main.o -lcvmlcpp -lz -lboost_iostreams -lgsl -lgslcblas
main.o: In function `_ZN7cvmlcpp25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEd.omp_fn.9':
main.cpp:(.text+0x11cc): undefined reference to `_ZN7cvmlcpp25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEd.omp_fn.9::C.467'
collect2: ld returned 1 exit status
scons: *** [shapes] Error 1
scons: building terminated because of errors.
make: *** [compile] Error 2

# No march=native --> FINE
$ make clean; make CNF=gcc BACKEND=gsl
....
g++ -o tinystr.o -c -pipe -I. -Wall -fopenmp -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ tinystr.cpp
g++ -o main.o -c -pipe -I. -Wall -fopenmp -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ main.cpp
g++ -o tinyxml.o -c -pipe -I. -Wall -fopenmp -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ tinyxml.cpp
g++ -o tinyxmlerror.o -c -pipe -I. -Wall -fopenmp -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ tinyxmlerror.cpp
g++ -o tinyxmlparser.o -c -pipe -I. -Wall -fopenmp -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ tinyxmlparser.cpp
g++ -o shapes -fopenmp -DUSE_GSL -L/user/l1/beekhof//lib/ tinystr.o tinyxml.o tinyxmlerror.o tinyxmlparser.o main.o -lcvmlcpp -lz -lboost_iostreams -lgsl -lgslcblas
scons: done building targets.


# No openmp --> FINE
$ make clean; make CNF=gcc BACKEND=gsl
....
g++ -o main.o -c -pipe -I. -Wall -march=native -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ main.cpp
g++ -o tinystr.o -c -pipe -I. -Wall -march=native -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ tinystr.cpp
g++ -o tinyxml.o -c -pipe -I. -Wall -march=native -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ tinyxml.cpp
g++ -o tinyxmlerror.o -c -pipe -I. -Wall -march=native -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ tinyxmlerror.cpp
g++ -o tinyxmlparser.o -c -pipe -I. -Wall -march=native -DNDEBUG -DUSE_GSL -I/user/l1/beekhof//include/ tinyxmlparser.cpp
g++ -o shapes -DUSE_GSL -L/user/l1/beekhof//lib/ tinystr.o tinyxml.o tinyxmlerror.o tinyxmlparser.o main.o -lcvmlcpp -lz -lboost_iostreams -lgsl -lgslcblas
scons: done building targets.

Comment 12 Richard Biener 2009-04-04 20:00:08 UTC
I do not see that undefined symbol required, but it _does_ print strangely

_ZN7cvmlcpp25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEd.omp_fn.9::C.467

it suggests that this was sort-of "demangled"
Comment 13 Richard Biener 2009-04-04 20:03:06 UTC
What does

nm mainpp.o | grep _ZN7cvmlcpp25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEd

print for you?
Comment 14 F. Beekhof 2009-04-04 20:14:45 UTC
For simplicty, in the preprocessed source, edit the Makefile, set
CXXFLAGS= -pipe -I. -Wall -fopenmp -march=native

Then,
gccbug39573$ make clean; make
rm -f *.o *~ shapes
gcc -pipe -I. -Wall -fopenmp -march=native   -c -o mainpp.o mainpp.cc
gcc -pipe -I. -Wall -fopenmp -march=native   -c -o tinystrpp.o tinystrpp.cc
gcc -pipe -I. -Wall -fopenmp -march=native   -c -o tinyxmlpp.o tinyxmlpp.cc
gcc -pipe -I. -Wall -fopenmp -march=native   -c -o tinyxmlerrorpp.o tinyxmlerrorpp.cc
gcc -pipe -I. -Wall -fopenmp -march=native   -c -o tinyxmlparserpp.o tinyxmlparserpp.cc
gcc -pipe -I. -Wall -fopenmp -march=native   -c -o SurfaceExtractorpp.o SurfaceExtractorpp.cc
gcc -o shapes -pipe -I. -Wall -fopenmp -march=native -lz -lboost_iostreams -lgsl -lgslcblas mainpp.o tinystrpp.o tinyxmlpp.o tinyxmlerrorpp.o tinyxmlparserpp.o SurfaceExtractorpp.o
mainpp.o: In function `_ZN7cvmlcpp25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEd.omp_fn.8':
mainpp.cc:(.text+0x1f76): undefined reference to `void cvmlcpp::extractSurfaceFromAdapter<shapes::ShapeSurfaceAdaptor_<double>, double>(shapes::ShapeSurfaceAdaptor_<double> const&, cvmlcpp::Geometry<double>&, double)::C.867'
collect2: ld returned 1 exit status
make: *** [shapes] Error 1

gccbug39573$ nm mainpp.o | grep _ZN7cvmlcpp25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEd
0000000000000000 W _ZN7cvmlcpp25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEd
00000000000019af t _ZN7cvmlcpp25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEd.omp_fn.10
0000000000001c7e t _ZN7cvmlcpp25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEd.omp_fn.8
0000000000001af2 t _ZN7cvmlcpp25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEd.omp_fn.9
Comment 15 Richard Biener 2009-04-04 20:45:28 UTC
Ok, I can see

        movl   $_ZZN7cvmlcpp25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEdE5C.907, %esi
        movl    $12, %ecx
        movq    56(%rsp), %rdi
        rep movsq
        movl    %r14d, %esi

but that's not on an omp thing.

Expanded from

;; offset = C.907
(insn 2176 2175 2177 /usr/local/include/cvmlcpp/volume/SurfaceExtractor:150 (parallel [
            (set (reg:DI 999)
                (plus:DI (reg/f:DI 54 virtual-stack-vars)
                    (const_int -832 [0xfffffffffffffcc0])))
            (clobber (reg:CC 17 flags))
        ]) -1 (nil))

(insn 2177 2176 2178 /usr/local/include/cvmlcpp/volume/SurfaceExtractor:150 (set (reg:DI 1000)
        (symbol_ref:DI ("_ZZN7cvmlcpp25extractSurfaceFromAdapterIN6shapes20ShapeSurfaceAdaptor_IdEEdEEvRKT_RNS_8GeometryIT0_EEdE5C.907") [flags 0x2] <var_decl 0xb18423f4 C.907>)) -1 (nil))

That DECL_ASSEMBLER_NAME is bogus.

mainpp.cc.004t.gimple:                static int C.907[8][3] = {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}, {0, 1, 0}, {1, 1, 0}, {1, 1, 1}, {0, 1, 1}};
mainpp.cc.004t.gimple:                                    offset = C.907;

huh.  Gimplified from

    int offset[8][3] = {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}, {0, 1, 0}, {1, 1, 0}, {1, 1, 1}, {0, 1, 1}};

this sounds like related to PR38615.
Comment 16 F. Beekhof 2009-04-05 08:16:48 UTC
Ok, this was the original code that fails
// Prepare points of cube relative to point in matrix.
typename iPoint3D::value_type offset [8] [3] = {
	{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1},
	{0, 1, 0}, {1, 1, 0}, {1, 1, 1}, {0, 1, 1} };

After adding "const", it is fine!
// Prepare points of cube relative to point in matrix.
const typename iPoint3D::value_type offset [8] [3] = {
	{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1},
	{0, 1, 0}, {1, 1, 0}, {1, 1, 1}, {0, 1, 1} };

Comment 17 Jakub Jelinek 2009-04-06 08:59:25 UTC
Smaller self-contained testcase:
int z;

void __attribute__((noinline))
bar (int *x)
{
  #pragma omp atomic
    z += x[2];
  x[2] += x[3];
}

int
main ()
{
  int i;
#pragma omp parallel for
  for (i = 0; i < 65536; i++)
    {
      int x[] =
        {
          0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1,
          0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1,
          0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1,
          0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1,
          0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1,
          0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1,
          0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1,
          0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1,
          0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1,
          0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1,
          0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1,
          0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1,
          0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1,
        };
      bar (x);
    }
}

I've increased the size of the array to make it fail regardless of the -mtune=
setting.
Comment 18 Jakub Jelinek 2009-04-08 20:05:01 UTC
Subject: Bug 39573

Author: jakub
Date: Wed Apr  8 20:04:45 2009
New Revision: 145772

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145772
Log:
	PR middle-end/39573
	* omp-low.c (expand_omp_taskreg): Finalize taskreg static local_decls
	variables.

	* libgomp.c++/pr39573.C: New test.

Added:
    trunk/libgomp/testsuite/libgomp.c++/pr39573.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/omp-low.c
    trunk/libgomp/ChangeLog

Comment 19 Jakub Jelinek 2009-04-08 20:13:48 UTC
Subject: Bug 39573

Author: jakub
Date: Wed Apr  8 20:13:26 2009
New Revision: 145773

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145773
Log:
	PR middle-end/39573
	* omp-low.c (expand_omp_taskreg): Finalize taskreg static local_decls
	variables.

	* libgomp.c++/pr39573.C: New test.

Added:
    branches/gcc-4_4-branch/libgomp/testsuite/libgomp.c++/pr39573.C
      - copied unchanged from r145772, trunk/libgomp/testsuite/libgomp.c++/pr39573.C
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/omp-low.c
    branches/gcc-4_4-branch/libgomp/ChangeLog

Comment 20 Jakub Jelinek 2009-04-08 20:14:20 UTC
Fixed for 4.4/4.5+ so far.
Comment 21 Andrew Pinski 2009-04-28 23:41:01 UTC
Fixed.