This is the mail archive of the gcc-patches@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]

Re: [PATCH][committed] Fix ICE in maybe_record_trace_start


On 02/23/2018 04:59 PM, Jeff Law wrote:
On 02/22/2018 03:59 AM, Tom de Vries wrote:
On 02/12/2018 07:32 PM, Jeff Law wrote:
diff --git a/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c
b/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c
new file mode 100644
index 00000000000..0ca0b9f034b
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c
@@ -0,0 +1,36 @@
+int foo;
+typedef long unsigned int size_t;
+typedef short unsigned int wchar_t;
+struct tm
+{
+  int tm_mday;
+  int tm_mon;
+  int tm_year;
+};
+size_t
+__strftime (wchar_t * s, size_t maxsize, const wchar_t * format,
const struct tm *tim_p)
+{
+  size_t count = 0;
+  int len = 0;
+  size_t i, ctloclen;
+  unsigned long width;
+  {
+    if (foo)
+      {
+    {
+      wchar_t *fmt = L"%s%.*d";
+      len = swprintf (&s[count], maxsize, fmt, "-", width, 0);
+    }
+    if ((count) >= maxsize)
+      return 0;
+      }
+    else
+      {
+    len =
+      swprintf (&s[count], maxsize - count, L"%.2d/%.2d/%.2d", 42,
99, 0);
+    if ((count) >= maxsize)
+      return 0;
+
+      }
+  }
+}

Hi,

when compiling this test for nvptx, the missing declaration for swprintf
results in this default declaration in the .s file based on the
arguments of the first call:
...
         .extern .func (.param.u32 %value_out) swprintf (.param.u64
%in_ar0, .param.u64 %in_ar1, .param.u64 %in_ar2, .param.u64 %in_ar3,
.param.u64 %in_ar4, .param.u32 %in_ar5);
...

and this error message when ptxas process the second call:
...
ptxas regs-arg-size.o, line 97; error   : Type or alignment of argument
does not match formal parameter '%in_ar3'
ptxas regs-arg-size.o, line 97; error   : Type or alignment of argument
does not match formal parameter '%in_ar4'
ptxas fatal   : Ptx assembly aborted due to errors
nvptx-as: ptxas returned 255 exit status
...

When adding a declaration in the source like so:
...
diff --git a/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c
b/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c
index 0ca0b9f034b..81943a2c459 100644
--- a/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c
+++ b/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c
@@ -1,6 +1,7 @@
  int foo;
  typedef long unsigned int size_t;
  typedef short unsigned int wchar_t;
+extern int swprintf(wchar_t *wcs, size_t maxlen, const wchar_t *format,
...);
  struct tm
  {
    int tm_mday;
...

the declaration changes to:
...
.extern .func (.param.u32 %value_out) swprintf (.param.u64 %in_ar0,
.param.u64 %in_ar1, .param.u64 %in_ar2, .param.u64 %in_ar3);
...
and test test-case passes.

Is it ok to update the test-case like this, or should it require
effective target 'untyped_assembly' (which is false for nvptx).
It's OK to update the test in either way -- I don't think either change
would compromise the test.  Adding the prototype seems like the better
choice to me.


Done.

I need to remember that PTX (and the PA) are much more sensitive to
these issues than any other port and once a testcase minimization is
complete to go back and make sure we have suitable prototypes.

I think the root cause here is that compile.exp uses "-w". Without that, a warning triggers:
...
regs-arg-size.c:22:10: warning: implicit declaration of function 'swprintf' [-Wimplicit-function-declaration]...
...
and the test for excess errors fails.

Thanks,
- Tom
[testsuite] Add missing function decl to regs-arg-size.c

2018-02-26  Tom de Vries  <tom@codesourcery.com>

	* gcc.c-torture/compile/regs-arg-size.c (swprintf): Declare.

---
 gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c b/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c
index 0ca0b9f..f5f0111 100644
--- a/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c
+++ b/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c
@@ -1,6 +1,7 @@
 int foo;
 typedef long unsigned int size_t;
 typedef short unsigned int wchar_t;
+extern int swprintf (wchar_t *wcs, size_t maxlen, const wchar_t *format, ...);
 struct tm
 {
   int tm_mday;

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