|
From: <sv...@va...> - 2012-07-20 00:17:24
|
florian 2012-07-20 01:17:16 +0100 (Fri, 20 Jul 2012)
New Revision: 12765
Log:
Add testcases for CU21. Update opcode table.
WRT the memcheck test: the good news is we get all the complaints
we want. The bad news is:
- the line numbers from within do_cu21 are off
- there are 2 complaints when attempting to convert from
an uninitialised input buffer instead of one. One of them has a
completely bogus line number.
Possibly due to bad debug info? Let's see what happens on machines
with more recent GCCs.
Added files:
trunk/memcheck/tests/s390x/cu21.c
trunk/memcheck/tests/s390x/cu21.stderr.exp
trunk/memcheck/tests/s390x/cu21.stdout.exp
trunk/memcheck/tests/s390x/cu21.vgtest
trunk/none/tests/s390x/cu21.c
trunk/none/tests/s390x/cu21.stderr.exp
trunk/none/tests/s390x/cu21.stdout.exp
trunk/none/tests/s390x/cu21.vgtest
trunk/none/tests/s390x/cu21_1.c
trunk/none/tests/s390x/cu21_1.stderr.exp
trunk/none/tests/s390x/cu21_1.stdout.exp
trunk/none/tests/s390x/cu21_1.vgtest
Modified directories:
trunk/memcheck/tests/s390x/
trunk/none/tests/s390x/
Modified files:
trunk/docs/internals/s390-opcodes.csv
trunk/memcheck/tests/s390x/Makefile.am
trunk/none/tests/s390x/Makefile.am
Modified: trunk/memcheck/tests/s390x/
Modified: trunk/none/tests/s390x/
Added: trunk/none/tests/s390x/cu21.stdout.exp (+212 -0)
===================================================================
--- trunk/none/tests/s390x/cu21.stdout.exp 2012-07-20 00:29:06 -23:00 (rev 12764)
+++ trunk/none/tests/s390x/cu21.stdout.exp 2012-07-20 01:17:16 +01:00 (rev 12765)
@@ -0,0 +1,212 @@
+
+------------- test1 ----------------
+UTF8: <none>
+ cc = 0
+ dst len: 0
+ src len: 0
+
+------------- test2.1 ----------------
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src len: 1
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 1
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 1
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 1
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 1
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 2
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 3
+
+------------- test2.2 ----------------
+UTF8: 00
+ cc = 0
+ dst address difference: 1 dst len: 999
+ src address difference: 2 src len: 1
+UTF8: c2 80 df bf
+ cc = 0
+ dst address difference: 4 dst len: 996
+ src address difference: 4 src len: 1
+UTF8: e0 a0 80 ed 9f bf ed b0 80
+ cc = 0
+ dst address difference: 9 dst len: 991
+ src address difference: 6 src len: 1
+UTF8: f0 90 80 80 f4 8f bf bf
+ cc = 0
+ dst address difference: 8 dst len: 992
+ src address difference: 8 src len: 1
+UTF8: f0 90 80 80 f4 8f bf bf
+ cc = 0
+ dst address difference: 8 dst len: 992
+ src address difference: 8 src len: 2
+UTF8: f0 90 80 80 f4 8f bf bf
+ cc = 0
+ dst address difference: 8 dst len: 992
+ src address difference: 8 src len: 3
+
+------------- test3.1 ----------------
+UTF8: <none>
+ cc = 1
+ dst len: 0
+ src address difference: 0 src len: 16
+UTF8: <none>
+ cc = 1
+ dst len: 0
+ src address difference: 0 src len: 18
+UTF8: <none>
+ cc = 1
+ dst len: 1
+ src address difference: 0 src len: 18
+UTF8: <none>
+ cc = 1
+ dst len: 0
+ src address difference: 0 src len: 22
+UTF8: <none>
+ cc = 1
+ dst len: 1
+ src address difference: 0 src len: 22
+UTF8: <none>
+ cc = 1
+ dst len: 2
+ src address difference: 0 src len: 22
+UTF8: <none>
+ cc = 1
+ dst len: 0
+ src address difference: 0 src len: 16
+UTF8: <none>
+ cc = 1
+ dst len: 1
+ src address difference: 0 src len: 16
+UTF8: <none>
+ cc = 1
+ dst len: 2
+ src address difference: 0 src len: 16
+UTF8: <none>
+ cc = 1
+ dst len: 3
+ src address difference: 0 src len: 16
+
+------------- test3.2 ----------------
+UTF8: 00 7f 47
+ cc = 1
+ dst address difference: 3 dst len: 0
+ src address difference: 6 src len: 10
+UTF8: c2 80 df bf
+ cc = 1
+ dst address difference: 4 dst len: 1
+ src address difference: 4 src len: 14
+UTF8: e0 a0 80 ed 9f bf
+ cc = 1
+ dst address difference: 6 dst len: 1
+ src address difference: 4 src len: 18
+UTF8: e0 a0 80 ed 9f bf
+ cc = 1
+ dst address difference: 6 dst len: 2
+ src address difference: 4 src len: 18
+UTF8: f0 90 80 80 f4 8f bf bf
+ cc = 1
+ dst address difference: 8 dst len: 1
+ src address difference: 8 src len: 8
+UTF8: f0 90 80 80 f4 8f bf bf
+ cc = 1
+ dst address difference: 8 dst len: 2
+ src address difference: 8 src len: 8
+UTF8: f0 90 80 80 f4 8f bf bf
+ cc = 1
+ dst address difference: 8 dst len: 3
+ src address difference: 8 src len: 8
+
+------------- test4 ----------------
+UTF8: 00 7f 47
+ cc = 0
+ dst address difference: 3 dst len: 3
+ src address difference: 6 src len: 0
+
+------------- test5 ----------------
+UTF8: f0 90 92 98
+ cc = 0
+ dst address difference: 4 dst len: 996
+ src address difference: 4 src len: 0
+UTF8: <none>
+ cc = 1
+ dst address difference: 0 dst len: 0
+ src address difference: 0 src len: 4
+
+------------- test6 ----------------
+UTF8: 00 7f 47 56 45 21 7b 3a
+ cc = 0
+ dst address difference: 8 dst len: 992
+ src address difference: 16 src len: 0
+UTF8: c2 80 df bf df 9f c2 8f c4 80 c5 bf d4 af d8 80 db bf
+ cc = 0
+ dst address difference: 18 dst len: 982
+ src address difference: 18 src len: 0
+UTF8: e0 a0 80 ed 9f bf ed b0 80 ef bf bf e0 a0 bf e1 a8 a1 e1 ac 90 e2 88 80 e2 89 9e e2 8b 89 ee 80 81
+ cc = 0
+ dst address difference: 33 dst len: 967
+ src address difference: 22 src len: 0
+UTF8: f0 90 80 80 f4 8f bf bf f3 86 a7 9d ed ba af ed b3 9c
+ cc = 0
+ dst address difference: 18 dst len: 982
+ src address difference: 16 src len: 0
+UTF8: 78 c8 80 ef bf bf f0 90 80 81
+ cc = 0
+ dst address difference: 10 dst len: 990
+ src address difference: 10 src len: 0
+
+------------- test7.1 ----------------
+UTF8: 10
+ cc = 0
+ dst address difference: 1 dst len: 999
+ src address difference: 2 src len: 0
+UTF8: 10
+ cc = 0
+ dst address difference: 1 dst len: 999
+ src address difference: 2 src len: 0
+
+------------- test7.2 ----------------
+UTF8: c2 8f
+ cc = 0
+ dst address difference: 2 dst len: 998
+ src address difference: 2 src len: 0
+UTF8: c2 8f
+ cc = 0
+ dst address difference: 2 dst len: 998
+ src address difference: 2 src len: 0
+
+------------- test7.3 ----------------
+UTF8: e0 a1 82
+ cc = 0
+ dst address difference: 3 dst len: 997
+ src address difference: 2 src len: 0
+UTF8: e0 a1 82
+ cc = 0
+ dst address difference: 3 dst len: 997
+ src address difference: 2 src len: 0
+
+------------- test7.4 ----------------
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 2
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 2
Added: trunk/none/tests/s390x/cu21.c (+269 -0)
===================================================================
--- trunk/none/tests/s390x/cu21.c 2012-07-20 00:29:06 -23:00 (rev 12764)
+++ trunk/none/tests/s390x/cu21.c 2012-07-20 01:17:16 +01:00 (rev 12765)
@@ -0,0 +1,269 @@
+#include <stdint.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "opcodes.h"
+
+#ifndef M3
+#define M3 0
+#endif
+
+/* The abstracted result of an CU21 insn */
+typedef struct {
+ uint64_t addr1; // target
+ uint64_t len1;
+ uint64_t addr2; // source
+ uint64_t len2;
+ uint32_t cc;
+} cu21_t;
+
+/* Define various input buffers. */
+
+/* U+0000 to U+007f: Result is 1 byte for each uint16_t */
+uint16_t pattern1[] = {
+ 0x0000, 0x007f, /* corner cases */
+ 0x0047, 0x0056, 0x0045, 0x0021, 0x007b, 0x003a /* misc */
+};
+
+/* U+0080 to U+07ff: Result is 2 bytes for each uint16_t */
+uint16_t pattern2[] = {
+ 0x0080, 0x07ff, /* corner cases */
+ 0x07df, 0x008f, 0x0100, 0x017f, 0x052f, 0x0600, 0x06ff /* misc */
+};
+
+/* U+0800 to U+d7ff: Result is 3 bytes for each uint16_t
+ U+dc00 to U+ffff: Result is 3 bytes for each uint16_t */
+uint16_t pattern3[] = {
+ 0x0800, 0xd7ff, /* corner cases */
+ 0xdc00, 0xffff, /* corner cases */
+ 0x083f, 0x1a21, 0x1b10, 0x2200, 0x225e, 0x22c9, 0xe001 /* misc */
+};
+
+/* U+d800 to U+dbff: Result is 4 bytes for each uint16_t pair */
+uint16_t pattern4[] = {
+ 0xd800, 0xdc00, /* left corner case */
+ 0xdbff, 0xdfff, /* right corner case */
+ 0xdada, 0xdddd, 0xdeaf, 0xdcdc /* misc */
+};
+
+/* Invalid low surrogate */
+uint16_t invalid[] = { 0xd801, 0x0098 };
+
+/* Mixed bytes */
+uint16_t mixed[] = {
+ 0x0078 /* 1 byte */,
+ 0x0200 /* 2 bytes */,
+ 0xffff /* 3 bytes */,
+ 0xd800, 0xdc01 /* 4 bytes */
+};
+
+/* This is the buffer for the converted bytes. */
+uint8_t buff[1000]; /* Large so we con'don't have to worry about it */
+
+void write_and_check(uint16_t *, unsigned, unsigned);
+
+
+static cu21_t
+do_cu21(uint8_t *dst, uint64_t dst_len, uint16_t *src, uint64_t src_len)
+{
+ int cc = 42;
+ cu21_t regs;
+
+ /* build up the register pairs */
+ register uint16_t *source asm("4") = src;
+ register uint64_t source_len asm("5") = src_len;
+ register uint8_t *dest asm("2") = dst;
+ register uint64_t dest_len asm("3") = dst_len;
+
+ asm volatile(
+ CU21(M3,2,4)
+ "ipm %2\n\t"
+ "srl %2,28\n\t"
+ : "+d"(dest), "+d"(source), "=d"(cc),
+ "+d"(source_len), "+d"(dest_len)
+ :
+ : "memory", "cc");
+
+ /* Capture register contents at end of cu21 */
+ regs.addr1 = (uint64_t)dest;
+ regs.len1 = dest_len;
+ regs.addr2 = (uint64_t)source;
+ regs.len2 = source_len;
+ regs.cc = cc;
+
+ return regs;
+}
+
+void
+run_test(uint8_t *dst, uint64_t dst_len, uint16_t *src, uint64_t src_len)
+{
+ int i;
+ cu21_t result;
+
+ result = do_cu21(dst, dst_len, src, src_len);
+
+ // Write out the converted bytes, if any
+ printf("UTF8: ");
+ if (dst_len - result.len1 == 0)
+ printf(" <none>");
+ else
+ for (i = 0; i < dst_len - result.len1; i++) {
+ printf(" %02x", dst[i]);
+ }
+ printf("\n");
+
+ printf(" cc = %d\n", result.cc);
+ if (dst != NULL)
+ printf(" dst address difference: %"PRId64, result.addr1 - (uint64_t)dst);
+ printf(" dst len: %"PRId64"\n", result.len1);
+
+ if (src != NULL)
+ printf(" src address difference: %"PRId64, result.addr2 - (uint64_t)src);
+ printf(" src len: %"PRId64"\n", result.len2);
+}
+
+int main()
+{
+ /* Length == 0, no memory should be read or written */
+ printf("\n------------- test1 ----------------\n");
+ run_test(NULL, 0, NULL, 0);
+
+ /* Test exhaustion of source length (source bytes are valid) */
+ printf("\n------------- test2.1 ----------------\n");
+
+ /* No character will be written to BUFF, i.e. loop in jitted code
+ is not iterated */
+ run_test(buff, sizeof buff, NULL, 1);
+ run_test(buff, sizeof buff, pattern1, 1);
+ run_test(buff, sizeof buff, pattern2, 1);
+ run_test(buff, sizeof buff, pattern3, 1);
+ run_test(buff, sizeof buff, pattern4, 1);
+ run_test(buff, sizeof buff, pattern4, 2);
+ run_test(buff, sizeof buff, pattern4, 3);
+
+ printf("\n------------- test2.2 ----------------\n");
+ /* At least one character will be written to BUFF, i.e. loop in jitted
+ code is iterated */
+ run_test(buff, sizeof buff, pattern1, 3);
+ run_test(buff, sizeof buff, pattern2, 5);
+ run_test(buff, sizeof buff, pattern3, 7);
+ run_test(buff, sizeof buff, pattern4, 9);
+ run_test(buff, sizeof buff, pattern4, 10);
+ run_test(buff, sizeof buff, pattern4, 11);
+
+ /* Test exhaustion of destination length (source bytes are valid) */
+ printf("\n------------- test3.1 ----------------\n");
+
+ /* No character will be written to BUFF, i.e. loop in jitted code
+ is not iterated */
+
+ /* Want to write a single byte */
+ run_test(NULL, 0, pattern1, sizeof pattern1);
+
+ /* Want to write two bytes */
+ run_test(NULL, 0, pattern2, sizeof pattern2);
+ run_test(NULL, 1, pattern2, sizeof pattern2);
+
+ /* Want to write three bytes */
+ run_test(NULL, 0, pattern3, sizeof pattern3);
+ run_test(NULL, 1, pattern3, sizeof pattern3);
+ run_test(NULL, 2, pattern3, sizeof pattern3);
+
+ /* Want to write four bytes */
+ run_test(NULL, 0, pattern4, sizeof pattern4);
+ run_test(NULL, 1, pattern4, sizeof pattern4);
+ run_test(NULL, 2, pattern4, sizeof pattern4);
+ run_test(NULL, 3, pattern4, sizeof pattern4);
+
+ printf("\n------------- test3.2 ----------------\n");
+ /* At least one character will be written to BUFF, i.e. loop in jitted
+ code is iterated */
+ run_test(buff, 3, pattern1, sizeof pattern1);
+
+ run_test(buff, 5, pattern2, sizeof pattern2);
+
+ run_test(buff, 7, pattern3, sizeof pattern3);
+ run_test(buff, 8, pattern3, sizeof pattern3);
+
+ run_test(buff, 9, pattern4, sizeof pattern4);
+ run_test(buff, 10, pattern4, sizeof pattern4);
+ run_test(buff, 11, pattern4, sizeof pattern4);
+
+ /* When both operands are exhausted, cc=0 takes precedence.
+ (test1 tests this for len == 0) */
+ printf("\n------------- test4 ----------------\n");
+ run_test(buff, 6, pattern1, 6);
+
+ /* Input has invalid low surrogate. */
+ printf("\n------------- test5 ----------------\n");
+ run_test(buff, sizeof buff, invalid, sizeof invalid);
+ run_test(buff, 0, invalid, sizeof invalid);
+
+ /* Convert all pattern buffers */
+ printf("\n------------- test6 ----------------\n");
+ run_test(buff, sizeof buff, pattern1, sizeof pattern1);
+ run_test(buff, sizeof buff, pattern2, sizeof pattern2);
+ run_test(buff, sizeof buff, pattern3, sizeof pattern3);
+ run_test(buff, sizeof buff, pattern4, sizeof pattern4);
+ run_test(buff, sizeof buff, mixed, sizeof mixed);
+
+ /* Make sure we only write the exact number of bytes (and not more) */
+ uint16_t pat[2];
+
+ /* Write 1 byte */
+ printf("\n------------- test7.1 ----------------\n");
+ pat[0] = 0x10;
+ write_and_check(pat, 2, 1);
+
+ /* Write 2 bytes */
+ printf("\n------------- test7.2 ----------------\n");
+ pat[0] = 0x8f;
+ write_and_check(pat, 2, 2);
+
+ /* Write 3 bytes */
+ printf("\n------------- test7.3 ----------------\n");
+ pat[0] = 0x842;
+ write_and_check(pat, 2, 3);
+
+ /* Write 4 bytes */
+ printf("\n------------- test7.4 ----------------\n");
+ pat[0] = 0xd842;
+ pat[1] = 0xdc42;
+ write_and_check(pat, 2, 4);
+
+ return 0;
+}
+
+
+void
+write_and_check_aux(uint16_t *input, unsigned num_input_bytes,
+ unsigned num_expected_output_bytes,
+ unsigned fill_byte)
+{
+ int num_errors, i;
+
+ /* Fill output buffer with FILL_BYTE */
+ memset(buff, fill_byte, sizeof buff);
+
+ /* Execute cu21 */
+ run_test(buff, sizeof buff, input, num_input_bytes);
+
+ /* Make sure the rest of the buffer is unmodified. */
+ num_errors = 0;
+ for (i = num_expected_output_bytes; i < sizeof buff; ++i)
+ if (buff[i] != fill_byte) ++num_errors;
+ if (num_errors)
+ fprintf(stderr, "*** wrote more than one byte\n");
+}
+
+void
+write_and_check(uint16_t *input, unsigned num_input_bytes,
+ unsigned num_expected_output_bytes)
+{
+ write_and_check_aux(input, num_input_bytes, num_expected_output_bytes, 0x0);
+
+ /* Run again with different fill pattern to make sure we did not write
+ an extra 0x0 byte */
+ write_and_check_aux(input, num_input_bytes, num_expected_output_bytes, 0xFF);
+}
Added: trunk/none/tests/s390x/cu21_1.vgtest (+2 -0)
===================================================================
--- trunk/none/tests/s390x/cu21_1.vgtest 2012-07-20 00:29:06 -23:00 (rev 12764)
+++ trunk/none/tests/s390x/cu21_1.vgtest 2012-07-20 01:17:16 +01:00 (rev 12765)
@@ -0,0 +1,2 @@
+prereq: ../../../tests/s390x_features s390x-etf3
+prog: cu21_1
Modified: trunk/none/tests/s390x/Makefile.am (+2 -1)
===================================================================
--- trunk/none/tests/s390x/Makefile.am 2012-07-20 00:29:06 -23:00 (rev 12764)
+++ trunk/none/tests/s390x/Makefile.am 2012-07-20 01:17:16 +01:00 (rev 12765)
@@ -7,7 +7,7 @@
and_EI or_EI xor_EI insert_EI mul_GE add_GE condloadstore \
op_exception fgx stck stckf stcke stfle cksm mvcl clcl troo \
trto trot trtt tr tre cij cgij clij clgij crj cgrj clrj clgrj \
- cs csg cds cdsg
+ cs csg cds cdsg cu21 cu21_1
check_PROGRAMS = $(INSN_TESTS) \
allexec \
@@ -33,3 +33,4 @@
ex_clone_LDFLAGS = -lpthread
tcxb_CFLAGS = $(AM_CFLAGS) -std=gnu99
+cu21_1_CFLAGS = $(AM_CFLAGS) -DM3=1
Modified: trunk/memcheck/tests/s390x/Makefile.am (+1 -1)
===================================================================
--- trunk/memcheck/tests/s390x/Makefile.am 2012-07-20 00:29:06 -23:00 (rev 12764)
+++ trunk/memcheck/tests/s390x/Makefile.am 2012-07-20 01:17:16 +01:00 (rev 12765)
@@ -2,7 +2,7 @@
dist_noinst_SCRIPTS = filter_stderr
-INSN_TESTS = cs csg cds cdsg
+INSN_TESTS = cs csg cds cdsg cu21
check_PROGRAMS = $(INSN_TESTS)
Added: trunk/none/tests/s390x/cu21.stderr.exp (+2 -0)
===================================================================
--- trunk/none/tests/s390x/cu21.stderr.exp 2012-07-20 00:29:06 -23:00 (rev 12764)
+++ trunk/none/tests/s390x/cu21.stderr.exp 2012-07-20 01:17:16 +01:00 (rev 12765)
@@ -0,0 +1,2 @@
+
+
Added: trunk/none/tests/s390x/cu21_1.stdout.exp (+212 -0)
===================================================================
--- trunk/none/tests/s390x/cu21_1.stdout.exp 2012-07-20 00:29:06 -23:00 (rev 12764)
+++ trunk/none/tests/s390x/cu21_1.stdout.exp 2012-07-20 01:17:16 +01:00 (rev 12765)
@@ -0,0 +1,212 @@
+
+------------- test1 ----------------
+UTF8: <none>
+ cc = 0
+ dst len: 0
+ src len: 0
+
+------------- test2.1 ----------------
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src len: 1
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 1
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 1
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 1
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 1
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 2
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 3
+
+------------- test2.2 ----------------
+UTF8: 00
+ cc = 0
+ dst address difference: 1 dst len: 999
+ src address difference: 2 src len: 1
+UTF8: c2 80 df bf
+ cc = 0
+ dst address difference: 4 dst len: 996
+ src address difference: 4 src len: 1
+UTF8: e0 a0 80 ed 9f bf ed b0 80
+ cc = 0
+ dst address difference: 9 dst len: 991
+ src address difference: 6 src len: 1
+UTF8: f0 90 80 80 f4 8f bf bf
+ cc = 0
+ dst address difference: 8 dst len: 992
+ src address difference: 8 src len: 1
+UTF8: f0 90 80 80 f4 8f bf bf
+ cc = 0
+ dst address difference: 8 dst len: 992
+ src address difference: 8 src len: 2
+UTF8: f0 90 80 80 f4 8f bf bf
+ cc = 0
+ dst address difference: 8 dst len: 992
+ src address difference: 8 src len: 3
+
+------------- test3.1 ----------------
+UTF8: <none>
+ cc = 1
+ dst len: 0
+ src address difference: 0 src len: 16
+UTF8: <none>
+ cc = 1
+ dst len: 0
+ src address difference: 0 src len: 18
+UTF8: <none>
+ cc = 1
+ dst len: 1
+ src address difference: 0 src len: 18
+UTF8: <none>
+ cc = 1
+ dst len: 0
+ src address difference: 0 src len: 22
+UTF8: <none>
+ cc = 1
+ dst len: 1
+ src address difference: 0 src len: 22
+UTF8: <none>
+ cc = 1
+ dst len: 2
+ src address difference: 0 src len: 22
+UTF8: <none>
+ cc = 1
+ dst len: 0
+ src address difference: 0 src len: 16
+UTF8: <none>
+ cc = 1
+ dst len: 1
+ src address difference: 0 src len: 16
+UTF8: <none>
+ cc = 1
+ dst len: 2
+ src address difference: 0 src len: 16
+UTF8: <none>
+ cc = 1
+ dst len: 3
+ src address difference: 0 src len: 16
+
+------------- test3.2 ----------------
+UTF8: 00 7f 47
+ cc = 1
+ dst address difference: 3 dst len: 0
+ src address difference: 6 src len: 10
+UTF8: c2 80 df bf
+ cc = 1
+ dst address difference: 4 dst len: 1
+ src address difference: 4 src len: 14
+UTF8: e0 a0 80 ed 9f bf
+ cc = 1
+ dst address difference: 6 dst len: 1
+ src address difference: 4 src len: 18
+UTF8: e0 a0 80 ed 9f bf
+ cc = 1
+ dst address difference: 6 dst len: 2
+ src address difference: 4 src len: 18
+UTF8: f0 90 80 80 f4 8f bf bf
+ cc = 1
+ dst address difference: 8 dst len: 1
+ src address difference: 8 src len: 8
+UTF8: f0 90 80 80 f4 8f bf bf
+ cc = 1
+ dst address difference: 8 dst len: 2
+ src address difference: 8 src len: 8
+UTF8: f0 90 80 80 f4 8f bf bf
+ cc = 1
+ dst address difference: 8 dst len: 3
+ src address difference: 8 src len: 8
+
+------------- test4 ----------------
+UTF8: 00 7f 47
+ cc = 0
+ dst address difference: 3 dst len: 3
+ src address difference: 6 src len: 0
+
+------------- test5 ----------------
+UTF8: <none>
+ cc = 2
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 4
+UTF8: <none>
+ cc = 2
+ dst address difference: 0 dst len: 0
+ src address difference: 0 src len: 4
+
+------------- test6 ----------------
+UTF8: 00 7f 47 56 45 21 7b 3a
+ cc = 0
+ dst address difference: 8 dst len: 992
+ src address difference: 16 src len: 0
+UTF8: c2 80 df bf df 9f c2 8f c4 80 c5 bf d4 af d8 80 db bf
+ cc = 0
+ dst address difference: 18 dst len: 982
+ src address difference: 18 src len: 0
+UTF8: e0 a0 80 ed 9f bf ed b0 80 ef bf bf e0 a0 bf e1 a8 a1 e1 ac 90 e2 88 80 e2 89 9e e2 8b 89 ee 80 81
+ cc = 0
+ dst address difference: 33 dst len: 967
+ src address difference: 22 src len: 0
+UTF8: f0 90 80 80 f4 8f bf bf f3 86 a7 9d ed ba af ed b3 9c
+ cc = 0
+ dst address difference: 18 dst len: 982
+ src address difference: 16 src len: 0
+UTF8: 78 c8 80 ef bf bf f0 90 80 81
+ cc = 0
+ dst address difference: 10 dst len: 990
+ src address difference: 10 src len: 0
+
+------------- test7.1 ----------------
+UTF8: 10
+ cc = 0
+ dst address difference: 1 dst len: 999
+ src address difference: 2 src len: 0
+UTF8: 10
+ cc = 0
+ dst address difference: 1 dst len: 999
+ src address difference: 2 src len: 0
+
+------------- test7.2 ----------------
+UTF8: c2 8f
+ cc = 0
+ dst address difference: 2 dst len: 998
+ src address difference: 2 src len: 0
+UTF8: c2 8f
+ cc = 0
+ dst address difference: 2 dst len: 998
+ src address difference: 2 src len: 0
+
+------------- test7.3 ----------------
+UTF8: e0 a1 82
+ cc = 0
+ dst address difference: 3 dst len: 997
+ src address difference: 2 src len: 0
+UTF8: e0 a1 82
+ cc = 0
+ dst address difference: 3 dst len: 997
+ src address difference: 2 src len: 0
+
+------------- test7.4 ----------------
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 2
+UTF8: <none>
+ cc = 0
+ dst address difference: 0 dst len: 1000
+ src address difference: 0 src len: 2
Added: trunk/none/tests/s390x/cu21_1.stderr.exp (+2 -0)
===================================================================
--- trunk/none/tests/s390x/cu21_1.stderr.exp 2012-07-20 00:29:06 -23:00 (rev 12764)
+++ trunk/none/tests/s390x/cu21_1.stderr.exp 2012-07-20 01:17:16 +01:00 (rev 12765)
@@ -0,0 +1,2 @@
+
+
Modified: trunk/docs/internals/s390-opcodes.csv (+1 -1)
===================================================================
--- trunk/docs/internals/s390-opcodes.csv 2012-07-20 00:29:06 -23:00 (rev 12764)
+++ trunk/docs/internals/s390-opcodes.csv 2012-07-20 01:17:16 +01:00 (rev 12765)
@@ -666,7 +666,7 @@
mvcos,"move with optional specifications",N/A,"privileged instruction"
lptea,"load page-table-entry address",N/A,"privileged instruction"
cu24,"convert utf-16 to utf-32","not implemented","open bugzilla"
-cu21,"convert utf-16 to utf-8","not implemented","open bugzilla"
+cu21,"convert utf-16 to utf-8",implemented
cu42,"convert utf-32 to utf-16","not implemented","open bugzilla"
cu41,"convert utf-32 to utf-8","not implemented","open bugzilla"
cu12,"convert utf-8 to utf-16","not implemented","open bugzilla"
Added: trunk/none/tests/s390x/cu21.vgtest (+1 -0)
===================================================================
--- trunk/none/tests/s390x/cu21.vgtest 2012-07-20 00:29:06 -23:00 (rev 12764)
+++ trunk/none/tests/s390x/cu21.vgtest 2012-07-20 01:17:16 +01:00 (rev 12765)
@@ -0,0 +1 @@
+prog: cu21
Added: trunk/memcheck/tests/s390x/cu21.vgtest (+2 -0)
===================================================================
--- trunk/memcheck/tests/s390x/cu21.vgtest 2012-07-20 00:29:06 -23:00 (rev 12764)
+++ trunk/memcheck/tests/s390x/cu21.vgtest 2012-07-20 01:17:16 +01:00 (rev 12765)
@@ -0,0 +1,2 @@
+prog: cu21
+vgopts: -q
Added: trunk/memcheck/tests/s390x/cu21.c (+115 -0)
===================================================================
--- trunk/memcheck/tests/s390x/cu21.c 2012-07-20 00:29:06 -23:00 (rev 12764)
+++ trunk/memcheck/tests/s390x/cu21.c 2012-07-20 01:17:16 +01:00 (rev 12765)
@@ -0,0 +1,115 @@
+#include <stdint.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "../../../none/tests/s390x/opcodes.h"
+
+/* Define various input buffers. */
+
+/* U+0000 to U+007f: Result is 1 byte for each uint16_t */
+uint16_t pattern1[] = {
+ 0x0000, 0x007f, /* corner cases */
+ 0x0047, 0x0056, 0x0045, 0x0021, 0x007b, 0x003a /* misc */
+};
+
+/* U+0080 to U+07ff: Result is 2 bytes for each uint16_t */
+uint16_t pattern2[] = {
+ 0x0080, 0x07ff, /* corner cases */
+ 0x07df, 0x008f, 0x0100, 0x017f, 0x052f, 0x0600, 0x06ff /* misc */
+};
+
+/* U+0800 to U+d7ff: Result is 3 bytes for each uint16_t
+ U+dc00 to U+ffff: Result is 3 bytes for each uint16_t */
+uint16_t pattern3[] = {
+ 0x0800, 0xd7ff, /* corner cases */
+ 0xdc00, 0xffff, /* corner cases */
+ 0x083f, 0x1a21, 0x1b10, 0x2200, 0x225e, 0x22c9, 0xe001 /* misc */
+};
+
+/* U+d800 to U+dbff: Result is 4 bytes for each uint16_t pair */
+uint16_t pattern4[] = {
+ 0xd800, 0xdc00, /* left corner case */
+ 0xdbff, 0xdfff, /* right corner case */
+ 0xdada, 0xdddd, 0xdeaf, 0xdcdc /* misc */
+};
+
+
+void
+do_cu21(uint8_t *dst, uint64_t dst_len, uint16_t *src, uint64_t src_len)
+{
+ /* build up the register pairs */
+ register uint16_t *source asm("4") = src;
+ register uint64_t source_len asm("5") = src_len;
+ register uint8_t *dest asm("2") = dst;
+ register uint64_t dest_len asm("3") = dst_len;
+
+ asm volatile(
+ CU21(0,2,4)
+ : "+d"(dest), "+d"(source), "+d"(source_len), "+d"(dest_len)
+ :
+ : "memory", "cc");
+ return;
+}
+
+int main()
+{
+ /*------------------------------------------------------------*/
+ /* Write to a too small buffer */
+ /*------------------------------------------------------------*/
+
+ /* Write 2 bytes into buffer of length 1 */
+ do_cu21(malloc(1), 10, pattern2, 2); // complaint (2 bytes)
+
+ /* Write 2 bytes into buffer of length 2 */
+ do_cu21(malloc(2), 10, pattern2, 2); // no complaint
+
+ /* Write 3 bytes into buffer of length 1 */
+ do_cu21(malloc(1), 10, pattern3, 2); // 2 complaints (3 = 2+1)
+
+ /* Write 3 bytes into buffer of length 2 */
+ do_cu21(malloc(2), 10, pattern3, 2); // complaint (1 byte)
+
+ /* Write 3 bytes into buffer of length 3 */
+ do_cu21(malloc(3), 10, pattern3, 2); // no complaint
+
+ /* Write 4 bytes into buffer of length 1 */
+ do_cu21(malloc(1), 10, pattern4, 4); // complaint (4 bytes)
+
+ /* Write 4 bytes into buffer of length 2 */
+ do_cu21(malloc(2), 10, pattern4, 4); // complaint (4 bytes)
+
+ /* Write 4 bytes into buffer of length 3 */
+ do_cu21(malloc(3), 10, pattern4, 4); // complaint (4 bytes)
+
+ /* Write 4 bytes into buffer of length 4 */
+ do_cu21(malloc(4), 10, pattern4, 4); // no complaint
+
+ /*------------------------------------------------------------*/
+ /* Read uninitialised data */
+ /*------------------------------------------------------------*/
+ uint8_t *input = malloc(10);
+
+ /* Input buffer is completely uninitialised */
+ do_cu21(malloc(4), 4, (void *)input, 2); // complaint
+
+ /* Read 2 bytes from input buffer. First byte is uninitialised */
+ input = malloc(10);
+ input[0] = 0x0;
+ do_cu21(malloc(4), 4, (void *)input, 2); // complaint
+
+ /* Read 2 bytes from input buffer. Second byte is uninitialised */
+ input = malloc(10);
+ input[1] = 0x0;
+ do_cu21(malloc(4), 4, (void *)input, 2); // complaint
+
+ /* Read 2 bytes from input buffer. All bytes are uninitialised */
+ input = malloc(10);
+ input[0] = input[1] = 0x0;
+ do_cu21(malloc(4), 4, (void *)input, 2); // no complaint
+
+ /* Write to NULL */
+ // do_cu21(NULL, 10, pattern1, sizeof pattern1); // complaint
+
+ return 0;
+}
Property changed: trunk/none/tests/s390x/cu21_1.c (+0 -0)
___________________________________________________________________
Name: svn:special
+ *
Added: trunk/none/tests/s390x/cu21_1.c (+1 -0)
===================================================================
--- trunk/none/tests/s390x/cu21_1.c 2012-07-20 00:29:06 -23:00 (rev 12764)
+++ trunk/none/tests/s390x/cu21_1.c 2012-07-20 01:17:16 +01:00 (rev 12765)
@@ -0,0 +1 @@
+link cu21.c
\ No newline at end of file
Added: trunk/memcheck/tests/s390x/cu21.stderr.exp (+73 -0)
===================================================================
--- trunk/memcheck/tests/s390x/cu21.stderr.exp 2012-07-20 00:29:06 -23:00 (rev 12764)
+++ trunk/memcheck/tests/s390x/cu21.stderr.exp 2012-07-20 01:17:16 +01:00 (rev 12765)
@@ -0,0 +1,73 @@
+Invalid write of size 2
+ at 0x........: do_cu21 (cu21.c:53)
+ by 0x........: main (cu21.c:62)
+ Address 0x........ is 0 bytes inside a block of size 1 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (cu21.c:62)
+
+Invalid write of size 2
+ at 0x........: do_cu21 (cu21.c:53)
+ by 0x........: main (cu21.c:68)
+ Address 0x........ is 0 bytes inside a block of size 1 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (cu21.c:68)
+
+Invalid write of size 1
+ at 0x........: do_cu21 (cu21.c:53)
+ by 0x........: main (cu21.c:68)
+ Address 0x........ is 1 bytes after a block of size 1 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (cu21.c:68)
+
+Invalid write of size 1
+ at 0x........: do_cu21 (cu21.c:53)
+ by 0x........: main (cu21.c:71)
+ Address 0x........ is 0 bytes after a block of size 2 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (cu21.c:71)
+
+Invalid write of size 4
+ at 0x........: do_cu21 (cu21.c:53)
+ by 0x........: main (cu21.c:77)
+ Address 0x........ is 0 bytes inside a block of size 1 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (cu21.c:77)
+
+Invalid write of size 4
+ at 0x........: do_cu21 (cu21.c:53)
+ by 0x........: main (cu21.c:80)
+ Address 0x........ is 0 bytes inside a block of size 2 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (cu21.c:80)
+
+Invalid write of size 4
+ at 0x........: do_cu21 (cu21.c:53)
+ by 0x........: main (cu21.c:83)
+ Address 0x........ is 0 bytes inside a block of size 3 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (cu21.c:83)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: do_cu21 (cu21.c:53)
+ by 0x........: main (cu21.c:94)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: do_cu21 (cu21.c:45)
+ by 0x........: main (cu21.c:94)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: do_cu21 (cu21.c:53)
+ by 0x........: main (cu21.c:99)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: do_cu21 (cu21.c:45)
+ by 0x........: main (cu21.c:99)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: do_cu21 (cu21.c:53)
+ by 0x........: main (cu21.c:104)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: do_cu21 (cu21.c:45)
+ by 0x........: main (cu21.c:104)
+
Property changed: trunk/none/tests/s390x (+0 -0)
___________________________________________________________________
Name: svn:ignore
- .deps
add
add_EI
add_GE
allexec
and
and_EI
clc
clcle
cvb
cvd
div
ex_clone
ex_sig
flogr
icm
insert
insert_EI
lam_stam
lpr
Makefile
Makefile.in
mul
mul_GE
mvst
or
or_EI
srst
sub
sub_EI
tcxb
xc
xor
xor_EI
stck
stcke
stckf
op_exception
fgx
condloadstore
fold_And16
stfle
op00
cksm
clcl
mvcl
troo
trot
trto
trtt
tr
tre
clrj
clgrj
crj
cgrj
clij
clgij
cij
cgij
cs
csg
cds
cdsg
+ .deps
add
add_EI
add_GE
allexec
and
and_EI
clc
clcle
cvb
cvd
div
ex_clone
ex_sig
flogr
icm
insert
insert_EI
lam_stam
lpr
Makefile
Makefile.in
mul
mul_GE
mvst
or
or_EI
srst
sub
sub_EI
tcxb
xc
xor
xor_EI
stck
stcke
stckf
op_exception
fgx
condloadstore
fold_And16
stfle
op00
cksm
clcl
mvcl
troo
trot
trto
trtt
tr
tre
clrj
clgrj
crj
cgrj
clij
clgij
cij
cgij
cs
csg
cds
cdsg
cu21
cu21_1
Added: trunk/memcheck/tests/s390x/cu21.stdout.exp (+0 -0)
===================================================================
Property changed: trunk/memcheck/tests/s390x (+0 -0)
___________________________________________________________________
Name: svn:ignore
- .deps
Makefile
Makefile.in
cs
csg
cds
cdsg
+ .deps
Makefile
Makefile.in
cs
csg
cds
cdsg
cu21
|
|
From: Christian B. <bor...@de...> - 2012-07-20 08:51:26
|
On 20/07/12 02:17, sv...@va... wrote:
> florian 2012-07-20 01:17:16 +0100 (Fri, 20 Jul 2012)
>
> New Revision: 12765
>
> Log:
> Add testcases for CU21. Update opcode table.
> WRT the memcheck test: the good news is we get all the complaints
> we want. The bad news is:
> - the line numbers from within do_cu21 are off
> - there are 2 complaints when attempting to convert from
> an uninitialised input buffer instead of one. One of them has a
> completely bogus line number.
>
> Possibly due to bad debug info? Let's see what happens on machines
> with more recent GCCs.
Same here. The code in question is:
00000000800005f4 <do_cu21>:
800005f4: eb bf f0 58 00 24 stmg %r11,%r15,88(%r15)
800005fa: a7 fb ff 40 aghi %r15,-192
800005fe: b9 04 00 bf lgr %r11,%r15
80000602: e3 20 b0 b8 00 24 stg %r2,184(%r11)
80000608: e3 30 b0 b0 00 24 stg %r3,176(%r11)
8000060e: e3 40 b0 a8 00 24 stg %r4,168(%r11)
80000614: e3 50 b0 a0 00 24 stg %r5,160(%r11)
8000061a: e3 40 b0 a8 00 04 lg %r4,168(%r11)
80000620: e3 50 b0 a0 00 04 lg %r5,160(%r11)
80000626: e3 20 b0 b8 00 04 lg %r2,184(%r11)
8000062c: e3 30 b0 b0 00 04 lg %r3,176(%r11)
80000632: b2 a6 00 24 cu21 %r2,%r4,0
80000636: e3 40 b1 30 00 04 lg %r4,304(%r11)
8000063c: eb bf b1 18 00 04 lmg %r11,%r15,280(%r11)
80000642: 07 f4 br %r4
And the debuginfo is:
> readelf --debug-dump=decodedline memcheck/tests/s390x/cu21
Decoded dump of debug contents of section .debug_line:
CU: init.c:
File name Line number Starting address
CU: /usr/include/cu21.c:
File name Line number Starting address
cu21.c 40 0x800005f4
cu21.c 42 0x8000061a
cu21.c 43 0x80000620
cu21.c 44 0x80000626
cu21.c 45 0x8000062c
cu21.c 47 0x80000636
cu21.c 53 0x80000636
[...]
As you can see valgrind can only print either 45 or 53 for the cu21.
Regarding the question why it prints both lines: I checked the IR and
we set IA to xx636 several times due to the if_condition_goto.
I experimented with this patch:
+static void
+if_condition_goto_noput(IRExpr *condition, Addr64 target)
+{
+ vassert(typeOfIRExpr(irsb->tyenv, condition) == Ity_I1);
+
+ stmt(IRStmt_Exit(condition, Ijk_Boring, IRConst_U64(target),
+ S390X_GUEST_OFFSET(guest_IA)));
+}
+
+
/* An unconditional branch. Target may or may not be known at instrumentation
time. */
static void
@@ -11224,7 +11234,7 @@
there are less than 2 bytes left, then the 2nd operand is exhausted
and we're done here. cc = 0 */
s390_cc_set(0);
- if_condition_goto(binop(Iop_CmpLT64U, mkexpr(len2), mkU64(2)),
+ if_condition_goto_noput(binop(Iop_CmpLT64U, mkexpr(len2), mkU64(2)),
guest_IA_next_instr);
/* There are at least two bytes there. Read them. */
@@ -11245,7 +11255,7 @@
IRExpr *not_enough_bytes =
mkite(binop(Iop_CmpLT64U, mkexpr(len2), mkU64(4)), mkU32(1), mkU32(0));
- if_condition_goto(binop(Iop_CmpEQ32,
+ if_condition_goto_noput(binop(Iop_CmpEQ32,
binop(Iop_And32, mkexpr(is_high_surrogate),
not_enough_bytes),
mkU32(1)), guest_IA_next_instr);
@@ -11271,7 +11281,7 @@
binop(Iop_And64, mkexpr(retval), mkU64(0xff));
s390_cc_set(2);
- if_condition_goto(binop(Iop_CmpEQ64, invalid_low_surrogate, mkU64(1)),
+ if_condition_goto_noput(binop(Iop_CmpEQ64, invalid_low_surrogate, mkU64(1)),
guest_IA_next_instr);
}
@@ -11281,7 +11291,7 @@
binop(Iop_Shr64, mkexpr(retval), mkU8(8)),
mkU64(0xff)));
s390_cc_set(1);
- if_condition_goto(binop(Iop_CmpLT64U, mkexpr(len1), mkexpr(num_bytes)),
+ if_condition_goto_noput(binop(Iop_CmpLT64U, mkexpr(len1), mkexpr(num_bytes)),
guest_IA_next_instr);
/* Extract the bytes to be stored at addr1 */
This makes the problem go away.
So here is MY question: Should if_condition_goto really do a put_IA? That was added
for t-chaining I think.
Can we remove that and do a dummy_put_IA in all users of if_condition_goto? This would
also remove several put_IA statements in the middle of a block
the IR of cu21 has lots of them).
Christian
|
|
From: Florian K. <br...@ac...> - 2012-07-20 15:58:59
|
On 07/20/2012 04:51 AM, Christian Borntraeger wrote: > On 20/07/12 02:17, sv...@va... wrote: > >> Possibly due to bad debug info? Let's see what happens on machines >> with more recent GCCs. > > Same here. The code in question is: > > 00000000800005f4 <do_cu21>: > 800005f4: eb bf f0 58 00 24 stmg %r11,%r15,88(%r15) > 800005fa: a7 fb ff 40 aghi %r15,-192 > 800005fe: b9 04 00 bf lgr %r11,%r15 > 80000602: e3 20 b0 b8 00 24 stg %r2,184(%r11) > 80000608: e3 30 b0 b0 00 24 stg %r3,176(%r11) > 8000060e: e3 40 b0 a8 00 24 stg %r4,168(%r11) > 80000614: e3 50 b0 a0 00 24 stg %r5,160(%r11) > 8000061a: e3 40 b0 a8 00 04 lg %r4,168(%r11) > 80000620: e3 50 b0 a0 00 04 lg %r5,160(%r11) > 80000626: e3 20 b0 b8 00 04 lg %r2,184(%r11) > 8000062c: e3 30 b0 b0 00 04 lg %r3,176(%r11) > 80000632: b2 a6 00 24 cu21 %r2,%r4,0 > 80000636: e3 40 b1 30 00 04 lg %r4,304(%r11) > 8000063c: eb bf b1 18 00 04 lmg %r11,%r15,280(%r11) > 80000642: 07 f4 br %r4 > > > And the debuginfo is: >> readelf --debug-dump=decodedline memcheck/tests/s390x/cu21 > Decoded dump of debug contents of section .debug_line: > > CU: init.c: > File name Line number Starting address > > CU: /usr/include/cu21.c: > File name Line number Starting address > cu21.c 40 0x800005f4 > > cu21.c 42 0x8000061a > cu21.c 43 0x80000620 > cu21.c 44 0x80000626 > cu21.c 45 0x8000062c > cu21.c 47 0x80000636 > cu21.c 53 0x80000636 Debuginfo is busted. There ought to be an entry for address 80000632. Perhaps this is related to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14022 which has been open for 7 years. Not sure, though. Adding -O0 did not make a difference. > As you can see valgrind can only print either 45 or 53 for the cu21. > > Regarding the question why it prints both lines: I checked the IR and > we set IA to xx636 several times due to the if_condition_goto. > I experimented with this patch: > snip > This makes the problem go away. > So here is MY question: Should if_condition_goto really do a put_IA? The last stmt in an IRSB needs to be a PUT. Otherwise you run into an assert. That said, we could use if_condition_goto_unput when building up the IR for a complex insn unless the conditional jump is the last stmt in the IRSB. I'd call it internal_if_condition_goto. > Can we remove that and do a dummy_put_IA in all users of if_condition_goto? An if_condition_goto does not do a dummy_put_IA.. I'd say, let's leave if_condition_goto as is and add internal_if_condition_goto and use the latter as appropriate. That will at least get rid of the duplicate complaints. Florian |
|
From: Christian B. <bor...@de...> - 2012-07-20 16:13:16
|
On 20/07/12 17:58, Florian Krohm wrote: > The last stmt in an IRSB needs to be a PUT. Otherwise you run into an > assert. That said, we could use if_condition_goto_unput when building up > the IR for a complex insn unless the conditional jump is the last stmt > in the IRSB. I'd call it internal_if_condition_goto. > >> Can we remove that and do a dummy_put_IA in all users of if_condition_goto? > > An if_condition_goto does not do a dummy_put_IA.. > I'd say, let's leave if_condition_goto as is and add > internal_if_condition_goto and use the latter as appropriate. What about if_condition_goto_early if_condition_goto_last to make it clearer were in IR this belongs? |
|
From: Florian K. <br...@ac...> - 2012-07-20 16:41:13
|
On 07/20/2012 12:12 PM, Christian Borntraeger wrote: > On 20/07/12 17:58, Florian Krohm wrote: >> >> I'd say, let's leave if_condition_goto as is and add >> internal_if_condition_goto and use the latter as appropriate. > > What about if_condition_goto_early if_condition_goto_last to make it clearer > were in IR this belongs? Yes, that's better. Let's use it. I'll make the change when you sleep :) Florian |