[Bug target/81763] Issues with BMI on 32bit x86 apps on GCC 7.1+

2018-01-26 Thread mike at fireburn dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81763

--- Comment #47 from Mike Lothian  ---
With the patch you've committed to gcc master, applied on top of GCC 7.3 I'm
now seeing the following error building Clang:

[294/954] /usr/bin/x86_64-pc-linux-gnu-g++ -m32 -D_FILE_OFFSET_BITS=64
-D_GNU_SOURCE -D_LARGEFILE_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Serialization
-I/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/lib/Serialization
-I/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/include -Iinclude
-I/usr/lib/llvm/7/include  -DNDEBUG -O2 -march=native -pipe
-mindirect-branch=thunk -mfunction-return=thunk -mindirect-branch-register
-fpermissive -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11
-Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wno-missing-field-initializers -Wdelete-non-virtual-dtor -Wno-comment
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual
-fno-strict-aliasing -pedantic -Wno-long-long -fPIC -MD -MT
lib/Serialization/CMakeFiles/clangSerialization.dir/ASTReader.cpp.o -MF
lib/Serialization/CMakeFiles/clangSerialization.dir/ASTReader.cpp.o.d -o
lib/Serialization/CMakeFiles/clangSerialization.dir/ASTReader.cpp.o -c
/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/lib/Serialization/ASTReader.cpp
FAILED: lib/Serialization/CMakeFiles/clangSerialization.dir/ASTReader.cpp.o
/usr/bin/x86_64-pc-linux-gnu-g++ -m32 -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
-D_LARGEFILE_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS -Ilib/Serialization
-I/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/lib/Serialization
-I/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/include -Iinclude
-I/usr/lib/llvm/7/include  -DNDEBUG -O2 -march=native -pipe
-mindirect-branch=thunk -mfunction-return=thunk -mindirect-branch-register
-fpermissive -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11
-Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wno-missing-field-initializers -Wdelete-non-virtual-dtor -Wno-comment
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual
-fno-strict-aliasing -pedantic -Wno-long-long -fPIC -MD -MT
lib/Serialization/CMakeFiles/clangSerialization.dir/ASTReader.cpp.o -MF
lib/Serialization/CMakeFiles/clangSerialization.dir/ASTReader.cpp.o.d -o
lib/Serialization/CMakeFiles/clangSerialization.dir/ASTReader.cpp.o -c
/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/lib/Serialization/ASTReader.cpp
In file included from
/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/include/clang/AST/APValue.h:20:0,
 from
/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/include/clang/AST/Decl.h:17,
 from
/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/include/clang/AST/DeclObjC.h:17,
 from
/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/include/clang/Serialization/ASTReader.h:17,
 from
/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/lib/Serialization/ASTReader.cpp:14:
/usr/lib/llvm/7/include/llvm/ADT/PointerIntPair.h: In instantiation of ‘struct
llvm::PointerIntPairInfo*>, 2,
llvm::PointerLikeTypeTraits*> > >’:
/usr/lib/llvm/7/include/llvm/ADT/PointerIntPair.h:56:57:   required from
‘PointerTy llvm::PointerIntPair::getPointer() const [with PointerTy =
llvm::PointerUnion*>; unsigned int IntBits = 2; IntType = unsigned int; PtrTraits
= llvm::PointerLikeTypeTraits*> >; Info =
llvm::PointerIntPairInfo*>, 2,
llvm::PointerLikeTypeTraits*> > >]’
/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/include/clang/AST/Decl.h:2859:39:
  required from here
/usr/lib/llvm/7/include/llvm/ADT/PointerIntPair.h:132:3: error: static
assertion failed: PointerIntPair with integer size too large for pointer
   static_assert(IntBits <= PtrTraits::NumLowBitsAvailable,
   ^
/usr/lib/llvm/7/include/llvm/ADT/PointerIntPair.h:147:42: warning: left shift
count >= width of type [-Wshift-count-overflow]
 ShiftedIntMask = (uintptr_t)(IntMask << IntShift)
 ~^~~~
/usr/lib/llvm/7/include/llvm/ADT/PointerIntPair.h:147:42: warning: right
operand of shift expression ‘(3 << 4294967295)’ is >= than the precision of the
left operand [-fpermissive]
/usr/lib/llvm/7/include/llvm/ADT/PointerIntPair.h: In 

[Bug target/81763] Issues with BMI on 32bit x86 apps on GCC 7.1+

2018-01-26 Thread mike at fireburn dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81763

--- Comment #42 from Mike Lothian  ---
With the patch in Comment 36 I get the following error compiling Clang

FAILED: lib/Lex/CMakeFiles/clangLex.dir/PPExpressions.cpp.o
/usr/bin/x86_64-pc-linux-gnu-g++ -m32 -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
-D_LARGEFILE_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS -Ilib/Lex
-I/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/lib/Lex
-I/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/include -Iinclude
-I/usr/lib/llvm/7/include  -DNDEBUG -O2 -march=native -pipe
-mindirect-branch=thunk -mfunction-return=thunk -mindirect-branch-register
-fpermissive -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11
-Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wno-missing-field-initializers -Wdelete-non-virtual-dtor -Wno-comment
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual
-fno-strict-aliasing -pedantic -Wno-long-long -fPIC -MD -MT
lib/Lex/CMakeFiles/clangLex.dir/PPExpressions.cpp.o -MF
lib/Lex/CMakeFiles/clangLex.dir/PPExpressions.cpp.o.d -o
lib/Lex/CMakeFiles/clangLex.dir/PPExpressions.cpp.o -c
/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/lib/Lex/PPExpressions.cpp
/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/lib/Lex/PPExpressions.cpp:
In function ‘bool EvaluateValue({anonymous}::PPValue&, clang::Token&,
DefinedTracker&, bool, clang::Preprocessor&)’:
/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/lib/Lex/PPExpressions.cpp:492:1:
internal compiler error: in gen_split_178, at config/i386/i386.md:8623
 }
 ^

[Bug target/81763] Issues with BMI on 32bit x86 apps on GCC 7.1+

2018-01-25 Thread mike at fireburn dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81763

--- Comment #39 from Mike Lothian  ---
I can confirm it fixes things for me too. 

Is that the final patch in Comment 36? If so I'll try and get the Gentoo devs
to include it in the GCC ebuilds

Will this be added to GCC 8.1 and 7.4?

Thanks again, this bug has been plaguing me for the last 8 months

[Bug target/81763] Issues with BMI on 32bit x86 apps on GCC 7.1+

2018-01-25 Thread mike at fireburn dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81763

--- Comment #26 from Mike Lothian  ---
Is this the patch you want us to test then:

diff -ur a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
--- a/gcc/config/i386/i386.md   2018-01-16 11:17:49.509247000 +
+++ b/gcc/config/i386/i386.md   2018-01-25 18:21:25.562225621 +
@@ -8586,7 +8586,7 @@
 (define_insn "*andndi3_doubleword"
   [(set (match_operand:DI 0 "register_operand" "=r,")
(and:DI
- (not:DI (match_operand:DI 1 "register_operand" "r,0"))
+ (not:DI (match_operand:DI 1 "register_operand" "0,0"))
  (match_operand:DI 2 "nonimmediate_operand" "rm,rm")))
(clobber (reg:CC FLAGS_REG))]
   "!TARGET_64BIT && TARGET_STV && TARGET_SSE2"

[Bug target/81763] Issues with BMI on 32bit x86 apps on GCC 7.1+

2018-01-05 Thread mike at fireburn dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81763

--- Comment #15 from Mike Lothian  ---
Created attachment 43041
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43041=edit
llvm-tblgen Working and Broken binaries

[Bug target/81763] Issues with BMI on 32bit x86 apps on GCC 7.1+

2018-01-05 Thread mike at fireburn dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81763

--- Comment #14 from Mike Lothian  ---
I've been playing around with GCC 7.2.0 again

When compiling a 32bit LLVM with -O2 -march=native, llvm-tblgen runs
indefinitely during the build so it never completes

Doing the same with -O2 -march=native -mno-bmi or using GCC 6.4.0 allows it to
build 

From what I can see llvm-tblgen is a C++ program

[Bug target/81763] Issues with BMI on 32bit x86 apps on GCC 7.1+

2017-08-09 Thread mike at fireburn dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81763

--- Comment #12 from Mike Lothian  ---
Created attachment 41960
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41960=edit
si_shader objdumps

[Bug target/81763] Issues with BMI on 32bit x86 apps on GCC 7.1+

2017-08-09 Thread mike at fireburn dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81763

--- Comment #11 from Mike Lothian  ---
So a lot of the segfaults I see are in si_shader so I thought I'd compile Mesa
with and without BMI and compare the onjdumps of the two .o files

CFLAGS="-O2 -march=native -pipe -mno-bmi -m32" CXXFLAGS="-O2 -march=native
-pipe -mno-bmi -m32" LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed
-fuse-ld=bfd -m32" ./autogen.sh --prefix=/usr --build=i686-pc-linux-gnu
--host=i686-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info
--datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib
--disable-dependency-tracking --disable-silent-rules
--docdir=/usr/share/doc/mesa- --htmldir=/usr/share/doc/mesa-/html
--libdir=/usr/lib32 --enable-dri --enable-glx --enable-shared-glapi
--enable-texture-float --enable-nine --disable-debug --enable-dri3 --enable-egl
--enable-gbm --enable-gles1 --enable-gles2 --enable-glx-tls --disable-libunwind
--enable-valgrind=no --enable-llvm-shared-libs --with-dri-drivers=,swrast,i965
--with-gallium-drivers=,swrast,radeonsi --with-vulkan-drivers=,intel,radeon
PYTHON2=/usr/bin/python2.7 --with-platforms=x11,surfaceless,wayland,drm
--enable-nine --enable-llvm --enable-omx --enable-va --enable-vdpau
--disable-xa --disable-xvmc --with-va-libdir=/usr/lib32/va/drivers
--disable-glx-read-only-text --disable-gallium-osmesa


CFLAGS="-O2 -march=native -pipe -m32" CXXFLAGS="-O2 -march=native -pipe -m32"
LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fuse-ld=bfd -m32"
./autogen.sh --prefix=/usr --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu
--mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share
--sysconfdir=/etc --localstatedir=/var/lib --disable-dependency-tracking
--disable-silent-rules --docdir=/usr/share/doc/mesa-
--htmldir=/usr/share/doc/mesa-/html --libdir=/usr/lib32 --enable-dri
--enable-glx --enable-shared-glapi --enable-texture-float --enable-nine
--disable-debug --enable-dri3 --enable-egl --enable-gbm --enable-gles1
--enable-gles2 --enable-glx-tls --disable-libunwind --enable-valgrind=no
--enable-llvm-shared-libs --with-dri-drivers=,swrast,i965
--with-gallium-drivers=,swrast,radeonsi --with-vulkan-drivers=,intel,radeon
PYTHON2=/usr/bin/python2.7 --with-platforms=x11,surfaceless,wayland,drm
--enable-nine --enable-llvm --enable-omx --enable-va --enable-vdpau
--disable-xa --disable-xvmc --with-va-libdir=/usr/lib32/va/drivers
--disable-glx-read-only-text --disable-gallium-osmesa

Were my configure options, and LLVM was compiled with -mno-bmi 

I'm attaching the dumps

[Bug target/81763] Issues with BMI on 32bit x86 apps on GCC 7.1+

2017-08-09 Thread mike at fireburn dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81763

--- Comment #10 from Mike Lothian  ---
Unfortunately it also depends on LLVM not just Mesa which makes it a much
bigger target for figuring this out

[Bug target/81763] Issues with BMI on 32bit x86 apps on GCC 7.1+

2017-08-08 Thread mike at fireburn dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81763

--- Comment #6 from Mike Lothian  ---
I tried the test case with

gcc -O2 -march=native test.c -o test

and 

gcc -O2 -march=native -mno-bmi test.c -o test

Both executables seem to run with no output

I've only seen the issue in radeonsi in Mesa with LLVM, I'm not sure what's
happening as the problem doesn't manifest when debugging is enabled so I'm not
sure how to create a smaller test case

[Bug target/81763] Issues with 32bit x86 apps on GCC 7.1+

2017-08-08 Thread mike at fireburn dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81763

--- Comment #3 from Mike Lothian  ---
So dropping the -march=native allows everything to work again no matter which
version of GCC

Just using -mbmi breaks things and using -march=native -mno-bmi allows it all
to work

This is on a Skylake processor with the following in /proc/cpuinfo

flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb
rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology
nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl
vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe
popcnt aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb
intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle
avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt xsaveopt xsavec
xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp

[Bug target/81763] Issues with 32bit x86 apps on GCC 7.1+

2017-08-07 Thread mike at fireburn dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81763

--- Comment #2 from Mike Lothian  ---
Sorry I should have been more clear, this is LLVM trunk

I'm using these flags: 

CFLAGS="-O2 -march=native -pipe"
CXXFLAGS="-O2 -march=native -pipe"
LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed"

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/7.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-7.1.0-r1/work/gcc-7.1.0/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/7.1.0
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.0/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/7.1.0
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/7.1.0/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/7.1.0/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.0/include/g++-v7
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/7.1.0/python
--enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt
--disable-werror --with-system-zlib --enable-nls --without-included-gettext
--enable-checking=release --with-bugurl=https://bugs.gentoo.org/
--with-pkgversion='Gentoo 7.1.0-r1 p1.1' --disable-esp --enable-libstdcxx-time
--enable-shared --enable-threads=posix --enable-__cxa_atexit
--enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64
--disable-altivec --disable-fixed-point --enable-targets=all --disable-libgcj
--enable-libgomp --disable-libmudflap --disable-libssp --disable-libcilkrts
--enable-libmpx --enable-vtable-verify --enable-libvtv --enable-lto --with-isl
--disable-isl-version-check --enable-libsanitizer --disable-default-pie
--disable-default-ssp
Thread model: posix
gcc version 7.1.0 (Gentoo 7.1.0-r1 p1.1)

[Bug c/81763] New: Issues with 32bit x86 apps on GCC 7.1+

2017-08-07 Thread mike at fireburn dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81763

Bug ID: 81763
   Summary: Issues with 32bit x86 apps on GCC 7.1+
   Product: gcc
   Version: 7.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mike at fireburn dot co.uk
  Target Milestone: ---

I've been seeing issues with 32bit x86 llvm & mesa when using GCC 7.1.0 and
I've just tested GCC 7.2 RC

When llvm & mesa are compiled with GCC 7.1.0+ and I run a 32bit glxgears it
segfaults, the 64bit version work fine and if I recompile with GCC 6.3.0
everything works fine too (games also segfault but glxgears is a nice cut down
example)

This is only with the radeonsi driver, i965 works fine

https://bugs.freedesktop.org/show_bug.cgi?id=101881

It would be nice to rule out a GCC issue before 7.2.0 is released, the last
time I tried turning on debugging the issue no longer manifested.

Is there anything you can think of that might help pinpoint the bug?