diff mbox

[1/5] symaddr: add test cases

Message ID 20180309023010.94475-2-luc.vanoostenryck@gmail.com (mailing list archive)
State Rejected, archived
Headers show

Commit Message

Luc Van Oostenryck March 9, 2018, 2:30 a.m. UTC
Add a few testcases showing problems introduced with the removal
of OP_SYMADDRs.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 validation/mem2reg/address-used00.c |  1 +
 validation/symaddr-op.c             | 18 ++++++++++++++++++
 validation/symaddr.c                | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
 create mode 100644 validation/symaddr-op.c
 create mode 100644 validation/symaddr.c
diff mbox

Patch

diff --git a/validation/mem2reg/address-used00.c b/validation/mem2reg/address-used00.c
index f2d6c87bd..a41f05c25 100644
--- a/validation/mem2reg/address-used00.c
+++ b/validation/mem2reg/address-used00.c
@@ -16,4 +16,5 @@  int foo(int **g, int j)
  * check-known-to-fail
  * check-output-ignore
  * check-output-excludes: ret\\..* \\$1
+ * check-output-contains: ret\\..* \\$0
  */
diff --git a/validation/symaddr-op.c b/validation/symaddr-op.c
new file mode 100644
index 000000000..c17c328f8
--- /dev/null
+++ b/validation/symaddr-op.c
@@ -0,0 +1,18 @@ 
+struct s {
+	int c;
+	char a[];
+} s;
+
+char foo(int *ptr, long i)
+{
+	return s.a[i];
+}
+
+/*
+ * check-name: symaddr-op
+ * check-command: test-linearize -m64 -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-excludes: add.64 .* <- s,
+ */
diff --git a/validation/symaddr.c b/validation/symaddr.c
new file mode 100644
index 000000000..97f640f91
--- /dev/null
+++ b/validation/symaddr.c
@@ -0,0 +1,32 @@ 
+int g;
+int a[3];
+int b[3];
+
+void usep(int*);
+
+int foo(void)
+{
+	int r = 0;
+	usep(&g);
+	usep(a);
+	usep(b + 1);
+	return r;
+}
+
+/*
+ * check-name: symaddr
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-start
+foo:
+.L0:
+	<entry-point>
+	call        usep, g
+	call        usep, a
+	add.64      %r4 <- b, $4
+	call        usep, %r4
+	ret.32      $0
+
+
+ * check-output-end
+ */