This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lto] Do not write out char_type_node with -funsigned-char
- From: Diego Novillo <dnovillo at google dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 9 Oct 2008 12:19:15 -0400
- Subject: [lto] Do not write out char_type_node with -funsigned-char
When -funsigned-char is used, we overwrite the char_type_node
with the contents of unsigned_char_type_node, but when we write
out the IL, we are still writing out the reference for
char_type_node.
This means that when lto1 starts, it re-builds expressions with
char_type_node, which causes confusion later on. Fixed with this
patch.
I've got another test case being reduced, but the original input
is enormous (it's been reducing for 3 days). I'll commit the
testcase afterward.
Tested on x86_64 and i686.
Diego.
* lto-function-out.c (output_tree): If EXPR is
char_type_node and -funsigned-char is used, emit
unsigned_char_type_node.
testsuite/ChangeLog
* gcc.dg/lto/20080924.c: Add -O2.
* gcc.dg/lto/20080917.c: Add -O2.
* g++.dg/lto/20080924.C: Add -O2.
* g++.dg/lto/20080917.C: Add -O2.
* g++.dg/lto/20080926.C: Add -O2.
Index: lto-function-out.c
===================================================================
--- lto-function-out.c (revision 141004)
+++ lto-function-out.c (working copy)
@@ -3157,6 +3157,9 @@ output_tree (struct output_block *ob, tr
void **slot;
struct lto_decl_slot d_slot;
+ if (flag_signed_char == 0 && expr == char_type_node)
+ expr = unsigned_char_type_node;
+
if (expr == NULL_TREE)
{
output_zero (ob);
Index: testsuite/gcc.dg/lto/20080924.c
===================================================================
--- testsuite/gcc.dg/lto/20080924.c (revision 141004)
+++ testsuite/gcc.dg/lto/20080924.c (working copy)
@@ -1,5 +1,5 @@
/* { dg-do assemble } */
-/* { dg-options "-flto-single -funsigned-char" } */
+/* { dg-options "-O2 -flto-single -funsigned-char" } */
typedef unsigned int size_t;
foo (const char *src, unsigned char *dst, size_t size)
{
Index: testsuite/gcc.dg/lto/20080917.c
===================================================================
--- testsuite/gcc.dg/lto/20080917.c (revision 141004)
+++ testsuite/gcc.dg/lto/20080917.c (working copy)
@@ -1,5 +1,5 @@
/* { dg-do assemble } */
-/* { dg-options "-flto-single -funsigned-char" } */
+/* { dg-options "-O2 -flto-single -funsigned-char" } */
int
foo (char *s, int flag)
{
Index: testsuite/g++.dg/lto/20080924.C
===================================================================
--- testsuite/g++.dg/lto/20080924.C (revision 141004)
+++ testsuite/g++.dg/lto/20080924.C (working copy)
@@ -1,5 +1,5 @@
// { dg-do assemble }
-// { dg-options "-flto-single -fno-strict-aliasing" }
+// { dg-options "-O2 -flto-single -fno-strict-aliasing" }
namespace ns
{
Index: testsuite/g++.dg/lto/20080917.C
===================================================================
--- testsuite/g++.dg/lto/20080917.C (revision 141004)
+++ testsuite/g++.dg/lto/20080917.C (working copy)
@@ -1,5 +1,5 @@
// { dg-do assemble }
-// { dg-options "-flto-single -funsigned-char" }
+// { dg-options "-O2 -flto-single -funsigned-char" }
int
foo (char *s, int flag)
{
Index: testsuite/g++.dg/lto/20080926.C
===================================================================
--- testsuite/g++.dg/lto/20080926.C (revision 141004)
+++ testsuite/g++.dg/lto/20080926.C (working copy)
@@ -1,4 +1,4 @@
// { dg-do assemble }
-// { dg-options "-flto-single -fno-strict-aliasing" }
+// { dg-options "-O2 -flto-single -fno-strict-aliasing" }
extern int foo();
void bar() { try { int i = foo(); } catch(int) { } }