This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa] argument initialization bug when inlining


Copy propagation exposed a bug in the tree-ssa inliner
(gcc.c-torture/compile/20030310-1.c).  Now that we inline after
gimplification, it may happen that the inliner takes argument
values directly from GIMPLE temporaries (which are already
widened appropriately).  But when the inliner emits assignments
from the values to the arguments, it's failing to emit the
reverse casts:

---------------------------------------------------------------------------
static inline void
foo (char accept)
{
  char s;
  while (s == accept) ;
}

static void
bar (void)
{
  char ch;
  foo (ch);
}
---------------------------------------------------------------------------

They are inlined+gimplified into:

---------------------------------------------------------------------------
bar ()
{
  int T.1;
  char ch;

  T.1 = (int)ch;
  {
    char accept;

    accept = T.1;
    {
      ...
    }
  }
}
---------------------------------------------------------------------------

The assignment 'accept = T.1' is wrong.  It should be 'accept = (char) T.1'
Otherwise the copy propagator in the SSA builder is tricked into
propagating 'T.1' in all uses of 'accept'.  This causes the RTL
expander to abort with mismatched operand modes.

Jason proposed calling convert() in initialize_inlined_parameters.
This fixes the bug but causes a failure when building libstdc++.

Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.26.2.23
diff -d -u -p -r1.26.2.23 tree-inline.c
--- tree-inline.c	1 Apr 2003 15:21:33 -0000	1.26.2.23
+++ tree-inline.c	2 Apr 2003 18:31:37 -0000
@@ -586,7 +586,8 @@ initialize_inlined_parameters (id, args,
 	{
 	  /* We want to use MODIFY_EXPR, not INIT_EXPR here so that we
 	     keep our trees in gimple form.  */
-	  init_stmt = build (MODIFY_EXPR, TREE_TYPE (p), var, value);
+	  init_stmt = build (MODIFY_EXPR, TREE_TYPE (p), var,
+			     convert (TREE_TYPE (var), value));
 	  init_stmts = add_stmt_to_compound (init_stmts, void_type_node,
 					     init_stmt);
 	}


The call to convert() is causing problems in the C++ front end.
I tried comparing the types to avoid calling convert()
unnecessarily, but Jason tells me that convert() should be a nop
when the types are the same.  Comparing type pointers doesn't
seem to work (I thought types were shared?).

We get an ICE while compiling demangle.cc:

---------------------------------------------------------------------------
/notnfs/dnovillo/BLD-tree-ssa-native.x86-64/gcc/xgcc -shared-libgcc -B/notnfs/dnovillo/BLD-tree-ssa-native.x86-64/gcc/ -nostdinc++ -L/notnfs/dnovillo/BLD-tree-ssa-native.x86-64/x86_64-unknown-linux-gnu/libstdc++-v3/src -L/notnfs/dnovillo/BLD-tree-ssa-native.x86-64/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs -B/home/dnovillo/tree-ssa/native.x86-64/x86_64-unknown-linux-gnu/bin/ -B/home/dnovillo/tree-ssa/native.x86-64/x86_64-unknown-linux-gnu/lib/ -isystem /home/dnovillo/tree-ssa/native.x86-64/x86_64-unknown-linux-gnu/include -nostdinc++ -I/notnfs/dnovillo/BLD-tree-ssa-native.x86-64/x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu -I/notnfs/dnovillo/BLD-tree-ssa-native.x86-64/x86_64-unknown-linux-gnu/libstdc++-v3/include -I/home/dnovillo/tree-ssa/src.x86-64/libstdc++-v3/libsupc++ -I/home/dnovillo/tree-ssa/src.x86-64/libstdc++-v3/libmath -O2 -g -O2 -g -O2 -D_GNU_SOURCE -fno-implicit-templates -Wall -Wno-format -W -Wwrite-strings -Winline -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -fimplicit-templates -c /home/dnovillo/tree-ssa/src.x86-64/libstdc++-v3/src/demangle.cc  -fPIC -DPIC -o .libs/demangle.o
/home/dnovillo/tree-ssa/src.x86-64/libstdc++-v3/src/demangle.cc: In function `
   char* __cxxabiv1::__cxa_demangle(const char*, char*, size_t*, int*)':
/home/dnovillo/tree-ssa/src.x86-64/libstdc++-v3/src/demangle.cc:143:   instantiated from `void std::__destroy_aux(_ForwardIterator, _ForwardIterator, __false_type) [with _ForwardIterator = __gnu_cxx::demangler::substitution_st*]'
/home/dnovillo/tree-ssa/src.x86-64/libstdc++-v3/src/demangle.cc:143:   instantiated from `void std::_Destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator = __gnu_cxx::demangler::substitution_st*]'
/home/dnovillo/tree-ssa/src.x86-64/libstdc++-v3/src/demangle.cc:301:   instantiated from `std::vector<_Tp, _Alloc>::~vector() [with _Tp = __gnu_cxx::demangler::substitution_st, _Alloc = std::allocator<char>]'
/home/dnovillo/tree-ssa/src.x86-64/libstdc++-v3/src/demangle.cc:300:   instantiated from `__gnu_cxx::demangler::session<Allocator>::session(const char*, int) [with Allocator = std::allocator<char>]'
/home/dnovillo/tree-ssa/src.x86-64/libstdc++-v3/src/demangle.cc:161:   instantiated from here
/home/dnovillo/tree-ssa/src.x86-64/libstdc++-v3/src/demangle.cc:143: error: no 
   matching function for call to `__false_type::__false_type(int)'
/notnfs/dnovillo/BLD-tree-ssa-native.x86-64/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/type_traits.h:91: error: candidates
   are: __false_type::__false_type()
/notnfs/dnovillo/BLD-tree-ssa-native.x86-64/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/type_traits.h:91: error: 
                  __false_type::__false_type(const __false_type&)
/home/dnovillo/tree-ssa/src.x86-64/libstdc++-v3/src/demangle.cc:101:   instantiated from `void std::__destroy_aux(_ForwardIterator, _ForwardIterator, __false_type) [with _ForwardIterator = __gnu_cxx::demangler::substitution_st*]'
/home/dnovillo/tree-ssa/src.x86-64/libstdc++-v3/src/demangle.cc:101:   instantiated from `void std::_Destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator = __gnu_cxx::demangler::substitution_st*]'
/home/dnovillo/tree-ssa/src.x86-64/libstdc++-v3/src/demangle.cc:143:   instantiated from `std::vector<_Tp, _Alloc>::~vector() [with _Tp = __gnu_cxx::demangler::substitution_st, _Alloc = std::allocator<char>]'
/home/dnovillo/tree-ssa/src.x86-64/libstdc++-v3/src/demangle.cc:301:   instantiated from here
/home/dnovillo/tree-ssa/src.x86-64/libstdc++-v3/src/demangle.cc:101: error: no 
   matching function for call to `__false_type::__false_type(int)'
/notnfs/dnovillo/BLD-tree-ssa-native.x86-64/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/type_traits.h:91: error: candidates
   are: __false_type::__false_type()
/notnfs/dnovillo/BLD-tree-ssa-native.x86-64/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/type_traits.h:91: error: 
                  __false_type::__false_type(const __false_type&)
/notnfs/dnovillo/BLD-tree-ssa-native.x86-64/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/stl_construct.h:101: internal compiler error: Segmentation
   fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
---------------------------------------------------------------------------


Thanks.  Diego.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]