[Bug target/66579] New: frv target: -gsplit-dwarf confuses assembler

2015-06-17 Thread nicstange at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66579

Bug ID: 66579
   Summary: frv target: -gsplit-dwarf confuses assembler
   Product: gcc
   Version: 5.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: nicstange at gmail dot com
  Target Milestone: ---

Created attachment 35797
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35797&action=edit
Testcase

Adding `-gsplit-dwarf' leads to doubly defined symbols even in trivial
testcases (see attached).

# gcc-5.1.0/frv-linux/bin/frv-linux-gcc -c -gsplit-dwarf -o test.o test.c
/tmp/cc2kwvh4.s: Assembler messages:
/tmp/cc2kwvh4.s:225: Error: symbol `.LSLT0' is already defined
/tmp/cc2kwvh4.s:229: Error: symbol `.LASLTP0' is already defined
/tmp/cc2kwvh4.s:254: Error: symbol `.LELTP0' is already defined
/tmp/cc2kwvh4.s:255: Error: symbol `.LELT0' is already defined

# gcc-5.1.0/frv-linux/bin/frv-linux-gcc -v
Using built-in specs.
COLLECT_GCC=./gcc-5.1.0/frv-linux/bin/frv-linux-gcc
COLLECT_LTO_WRAPPER=/mnt/scratch/nic/cc/gcc-5.1.0/frv-linux/libexec/gcc/frv-linux/5.1.0/lto-wrapper
Target: frv-linux
Configured with: ../gcc-5.1.0/configure
--prefix=/mnt/scratch/nic/cc/gcc-5.1.0/frv-linux --target=frv-linux
--target=frv-linux --enable-targets=all --enable-languages=c --without-headers
--enable-sjlj-exceptions --with-system-libunwind --disable-nls
--disable-threads --disable-shared --disable-libmudflap --disable-libssp
--disable-libgomp --disable-decimal-float --enable-checking=release
--disable-bootstrap --disable-multilib --host=x86_64-linux-gnu
--build=x86_64-linux-gnu --with-newlib : (reconfigured) ../gcc-5.1.0/configure
--prefix=/mnt/scratch/nic/cc/gcc-5.1.0/frv-linux --target=frv-linux
--target=frv-linux --enable-targets=all --enable-languages=c --without-headers
--enable-sjlj-exceptions --with-system-libunwind --disable-nls
--disable-threads --disable-shared --disable-libmudflap --disable-libssp
--disable-libgomp --disable-decimal-float --enable-checking=release
--disable-bootstrap --disable-multilib --host=x86_64-linux-gnu
--build=x86_64-linux-gnu --with-newlib --disable-libquadmath : (reconfigured)
../gcc-5.1.0/configure --prefix=/mnt/scratch/nic/cc/gcc-5.1.0/frv-linux
--target=frv-linux --target=frv-linux --enable-targets=all --enable-languages=c
--without-headers --enable-sjlj-exceptions --with-system-libunwind
--disable-nls --disable-threads --disable-shared --disable-libmudflap
--disable-libssp --disable-libgomp --disable-decimal-float
--enable-checking=release --disable-bootstrap --disable-multilib
--host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-newlib
--disable-libquadmath --disable-libatomic
Thread model: single
gcc version 5.1.0 (GCC)


[Bug target/66579] frv target: -gsplit-dwarf confuses assembler

2015-06-17 Thread nicstange at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66579

--- Comment #1 from Nicolai Stange  ---
Created attachment 35798
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35798&action=edit
Output of `gcc -S -gsplit-dwarf' on Testcase


[Bug c/66963] New: __builtin_constant_p and __builtin_choose_expr do not agree on what is a constexpr with -O2

2015-07-21 Thread nicstange at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66963

Bug ID: 66963
   Summary: __builtin_constant_p and __builtin_choose_expr do not
agree on what is a constexpr with -O2
   Product: gcc
   Version: 5.1.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: nicstange at gmail dot com
  Target Milestone: ---

The first argument to __builtin_choose_expr() must be a constant expression.

However, at -O2, the following does not work:

  int foo (void)
  {
const int a = 0;
return __builtin_choose_expr(__builtin_choose_expr(__builtin_constant_p(a +
1), a + 1, 0),
 0, 0);
  }

test.c: In function ‘foo’:
test.c:4:10: error: first argument to ‘__builtin_choose_expr’ not a constant
   return __builtin_choose_expr(__builtin_choose_expr(__builtin_constant_p(a +
1), a + 1, 0),
  ^

Obviously, __builtin_constant_p() recognizes 'a+1' as being constant-foldable
and returns nonzero. This makes the inner __builtin_choose_expr() select its
second argument, i.e. 'a+1'. The outer __builtin_choose_expr() in turn refuses
to accept that 'a+1' as a constant expression for its condition argument
because it does not recognize it as a constexpr.


As a workaround, you can wrap the 'a+1' in a __builtin_expect() which seems to
apply constant-folding in the same way the __builtin_constant_p() does:
  __builtin_choose_expr(__builtin_choose_expr(__builtin_constant_p(a + 1),
  __builtin_expect(a + 1, 1), 0),
0, 0);

Thus, it looks like constant folding is not applied to
__builtin_choose_expr()'s first argument.

[Bug c/66963] __builtin_constant_p and __builtin_choose_expr do not agree on what is a constexpr with -O2

2015-07-21 Thread nicstange at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66963

--- Comment #3 from Nicolai Stange  ---
(In reply to Andrew Pinski from comment #1)
> I thought this is documented somewhere but __builtin_choose_expr only really
> accept constant literals and not constexprs.

https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
explicitly mentions integer constant expressions though. Quote: "This built-in
function returns exp1 if const_exp, which is an integer constant expression, is
nonzero."


[Bug c/66963] __builtin_constant_p and __builtin_choose_expr do not agree on what is a constexpr with -O2

2015-07-21 Thread nicstange at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66963

--- Comment #4 from Nicolai Stange  ---
Sorry, misunderstanding at my side. You probably did not mean constexprs in the
sense of C99, 6.6, but constexprs in the sense of constant folded expressions.


[Bug c/66963] __builtin_constant_p and __builtin_choose_expr do not agree on what is a constexpr with -O2

2015-07-28 Thread nicstange at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66963

--- Comment #6 from Nicolai Stange  ---
Thank you for your clarifications, Andrew and Joseph.

As far as I am concerned, this bug can be marked as resolved/rejected/whatever
you like.