aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-08-15 09:55:19 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-06-23 07:46:40 +0200
commitc8fac68af94b9d23b64e844a283f16b9bed2f9e0 (patch)
treecc5ace2a1e618680ce141e5b0aa6ad7066bad21c /validation
parentff7f001bef9aa88ff951d61ec10772e7d2143180 (diff)
downloadsparse-dev-c8fac68af94b9d23b64e844a283f16b9bed2f9e0.tar.gz
cast: specialize cast from pointers
Currently all casts to pointers are processed alike. This is simple but rather unconvenient in later phases as this correspond to different operations that obeys to different rules and which later need extra checks. Change this by using a specific instructions (OP_UTPTR) for [unsigned] integer to pointers. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/linear/bool-cast-lp32.c19
-rw-r--r--validation/linear/bool-cast-lp64.c18
-rw-r--r--validation/linear/bool-cast.c1
-rw-r--r--validation/linear/cast-kinds.c8
-rw-r--r--validation/optim/kill-casts.c1
5 files changed, 43 insertions, 4 deletions
diff --git a/validation/linear/bool-cast-lp32.c b/validation/linear/bool-cast-lp32.c
new file mode 100644
index 00000000..44a650f4
--- /dev/null
+++ b/validation/linear/bool-cast-lp32.c
@@ -0,0 +1,19 @@
+extern int ffun(void);
+typedef void *vdp;
+typedef int *sip;
+
+static _Bool fvdp_i(vdp a) { return a; }
+static _Bool fvdp_e(vdp a) { return (_Bool)a; }
+static _Bool fsip_i(sip a) { return a; }
+static _Bool fsip_e(sip a) { return (_Bool)a; }
+static _Bool ffun_i(void) { return ffun; }
+static _Bool ffun_e(void) { return (_Bool)ffun; }
+
+/*
+ * check-name: bool-cast-pointer
+ * check-command: test-linearize -m32 -fdump-ir $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-excludes: ptrtu\\.
+ */
diff --git a/validation/linear/bool-cast-lp64.c b/validation/linear/bool-cast-lp64.c
new file mode 100644
index 00000000..9b2a020a
--- /dev/null
+++ b/validation/linear/bool-cast-lp64.c
@@ -0,0 +1,18 @@
+extern int ffun(void);
+typedef void *vdp;
+typedef int *sip;
+
+static _Bool fvdp_i(vdp a) { return a; }
+static _Bool fvdp_e(vdp a) { return (_Bool)a; }
+static _Bool fsip_i(sip a) { return a; }
+static _Bool fsip_e(sip a) { return (_Bool)a; }
+static _Bool ffun_i(void) { return ffun; }
+static _Bool ffun_e(void) { return (_Bool)ffun; }
+
+/*
+ * check-name: bool-cast-pointer
+ * check-command: test-linearize -m64 -fdump-ir $file
+ *
+ * check-output-ignore
+ * check-output-excludes: ptrtu\\.
+ */
diff --git a/validation/linear/bool-cast.c b/validation/linear/bool-cast.c
index 094f4438..43276a46 100644
--- a/validation/linear/bool-cast.c
+++ b/validation/linear/bool-cast.c
@@ -28,6 +28,7 @@ static _Bool fdbl_e(dbl a) { return (_Bool)a; }
* check-output-ignore
* check-output-excludes: cast\\.
* check-output-excludes: fcvt[us]\\.
+ * check-output-excludes: ptrtu\\.
* check-output-pattern(12): setne\\.
* check-output-pattern(2): fcmpune\\.
*/
diff --git a/validation/linear/cast-kinds.c b/validation/linear/cast-kinds.c
index 1742cd1e..6683ea93 100644
--- a/validation/linear/cast-kinds.c
+++ b/validation/linear/cast-kinds.c
@@ -88,7 +88,7 @@ vptr_2_int:
iptr_2_int:
.L8:
<entry-point>
- cast.32 %r14 <- (64) %arg1
+ ptrtu.32 %r14 <- (64) %arg1
ret.32 %r14
@@ -136,7 +136,7 @@ vptr_2_uint:
iptr_2_uint:
.L22:
<entry-point>
- cast.32 %r35 <- (64) %arg1
+ ptrtu.32 %r35 <- (64) %arg1
ret.32 %r35
@@ -184,7 +184,7 @@ vptr_2_long:
iptr_2_long:
.L36:
<entry-point>
- cast.64 %r56 <- (64) %arg1
+ ptrtu.64 %r56 <- (64) %arg1
ret.64 %r56
@@ -232,7 +232,7 @@ vptr_2_ulong:
iptr_2_ulong:
.L50:
<entry-point>
- cast.64 %r77 <- (64) %arg1
+ ptrtu.64 %r77 <- (64) %arg1
ret.64 %r77
diff --git a/validation/optim/kill-casts.c b/validation/optim/kill-casts.c
index c375f5fb..140b8d20 100644
--- a/validation/optim/kill-casts.c
+++ b/validation/optim/kill-casts.c
@@ -21,4 +21,5 @@ void foo(struct s *x)
* check-output-excludes: cast\\.
* check-output-excludes: fcvt[us]\\.
* check-output-excludes: utptr\\.
+ * check-output-excludes: ptrtu\\.
*/