public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/42722]  New: move_by_pieces() incorrectly pushes structures to stack
@ 2010-01-13  9:44 shcherbakov at daad-alumni dot de
  2010-01-30 15:34 ` [Bug middle-end/42722] " steven at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 18+ messages in thread
From: shcherbakov at daad-alumni dot de @ 2010-01-13  9:44 UTC (permalink / raw)
  To: gcc-bugs

The move_by_pieces() function incorrectly works on targets with enabled
PUSH_ARGS that support post-increment loads. To reproduce the bug, the
following code should be compiled:

struct test { int a, b, c, d, e, f; } //Enough fields to pass structure in
stack
void func2(test copy);
void func1(test copy) {func2(copy);}

Every time a copy of our big structure is pushed to stack, its fields will go
in reverse order. This happens due to a bug in move_by_pieces() function from
expr.c that generates code for pushing a memory block in stack. 
This happens because if the target supports post-increment addressing, the
USE_LOAD_POST_INCREMENT() condition is met and the memory block to be pushed is
parsed from start to end using autoincrement addressing. The "reverse" flag
specifying that the push statements should traverse the block from end to start
is then ignored.
The proposed fix explicitly disables using post-increment mode if the "reverse"
flag is set.

The following patch fixes the problem:
---------------------------------------------
--- expr.old    Thu Aug 20 00:52:11 2009
+++ expr.new    Tue Jan 12 23:32:05 2010
@@ -952,13 +952,13 @@
       if (USE_LOAD_PRE_DECREMENT (mode) && data.reverse && ! data.autinc_from)
        {
          data.from_addr = copy_addr_to_reg (plus_constant (from_addr, len));
          data.autinc_from = 1;
          data.explicit_inc_from = -1;
        }
-      if (USE_LOAD_POST_INCREMENT (mode) && ! data.autinc_from)
+      if (USE_LOAD_POST_INCREMENT (mode) && !data.reverse && !
data.autinc_from)
        {
          data.from_addr = copy_addr_to_reg (from_addr);
          data.autinc_from = 1;
          data.explicit_inc_from = 1;
        }
       if (!data.autinc_from && CONSTANT_P (from_addr))


-- 
           Summary: move_by_pieces() incorrectly pushes structures to stack
           Product: gcc
           Version: 4.4.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: shcherbakov at daad-alumni dot de
 GCC build triplet: all
  GCC host triplet: all
GCC target triplet: msp430-gcc


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42722


^ permalink raw reply	[flat|nested] 18+ messages in thread
[parent not found: <bug-42722-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2021-08-16 22:29 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-13  9:44 [Bug middle-end/42722] New: move_by_pieces() incorrectly pushes structures to stack shcherbakov at daad-alumni dot de
2010-01-30 15:34 ` [Bug middle-end/42722] " steven at gcc dot gnu dot org
2010-01-30 15:37 ` shcherbakov at daad-alumni dot de
2010-01-30 16:01 ` rguenth at gcc dot gnu dot org
2010-01-30 19:54 ` mikpe at it dot uu dot se
2010-01-30 20:08 ` shcherbakov at daad-alumni dot de
2010-01-30 21:24 ` mikpe at it dot uu dot se
2010-01-30 21:30 ` shcherbakov at daad-alumni dot de
2010-01-30 21:57 ` mikpe at it dot uu dot se
2010-01-30 22:48 ` shcherbakov at daad-alumni dot de
2010-02-09  8:58 ` mikpe at it dot uu dot se
2010-02-10 12:45 ` shcherbakov at daad-alumni dot de
     [not found] <bug-42722-4@http.gcc.gnu.org/bugzilla/>
2011-02-21  9:46 ` bigotp at acm dot org
2011-02-21  9:48 ` bigotp at acm dot org
2011-02-21  9:48 ` bigotp at acm dot org
2011-02-21  9:51 ` bigotp at acm dot org
2011-02-21  9:53 ` bigotp at acm dot org
2021-08-16 22:29 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).