public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Visium] Fix gcc.dg/compat/scalar-by-value-4/scalar-return-4
@ 2016-10-12 21:05 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2016-10-12 21:05 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 435 bytes --]

There is a missing big-endian correction when types smaller than a word are 
passed through va_arg without promotion like _Complex char.

Tested on visium-elf, applied on the mainline.


2016-10-12  Eric Botcazou  <ebotcazou@adacore.com>

	* config/visium/visium.c (visium_gimplify_va_arg): Emit a big-endian
	correction if the type is smaller than a word.
	(visium_select_cc_mode): Add ... fall through ... comment.

-- 
Eric Botcazou

[-- Attachment #2: visium_va_arg.diff --]
[-- Type: text/x-patch, Size: 1272 bytes --]

Index: config/visium/visium.c
===================================================================
--- config/visium/visium.c	(revision 240969)
+++ config/visium/visium.c	(working copy)
@@ -1626,8 +1626,8 @@ visium_gimplify_va_arg (tree valist, tre
      7:   {
      8:     bytes = 0;
      9:     addr_rtx = ovfl;
-     10:     ovfl += rsize;
-     11:   }
+     10:    ovfl += rsize;
+     11:  }
 
    */
 
@@ -1691,6 +1691,16 @@ visium_gimplify_va_arg (tree valist, tre
   gimplify_and_add (t, pre_p);
   t = build1 (LABEL_EXPR, void_type_node, lab_over);
   gimplify_and_add (t, pre_p);
+
+  /* Emit a big-endian correction if size < UNITS_PER_WORD.  */
+  if (size < UNITS_PER_WORD)
+    {
+      t = build2 (POINTER_PLUS_EXPR, TREE_TYPE (addr), addr,
+		  size_int (UNITS_PER_WORD - size));
+      t = build2 (MODIFY_EXPR, void_type_node, addr, t);
+      gimplify_and_add (t, pre_p);
+    }
+
   addr = fold_convert (ptrtype, addr);
 
   return build_va_arg_indirect_ref (addr);
@@ -2848,6 +2858,9 @@ visium_select_cc_mode (enum rtx_code cod
     case CONST_INT:
       /* This is a degenerate case, typically an uninitialized variable.  */
       gcc_assert (op0 == constm1_rtx);
+
+      /* ... fall through ... */
+
     case REG:
     case AND:
     case IOR:

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-10-12 21:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-12 21:05 [Visium] Fix gcc.dg/compat/scalar-by-value-4/scalar-return-4 Eric Botcazou

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).