[PATCH] fix-return: remove special case for single return

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



During the linearization of a function, returns are directly
linearized as phi-sources and the exit BB contains the
corresponding phi-node and the unique OP_RET.

There is also a kind of optimization that is done if there is
only a single a return statement and thus a single phi-source:
the phi-source and the phi-node is simply ignored and the
unique value is directly used by the OP_RET instruction.

While this optimization make sense it also has some cons:
- the phi-node and the phi-source are created anyway and will
  need to be removed during cleanup.
- the corresponding optimization need to be done anyway during
  simplification
- it's only a tiny special case which save very litte.

So, keep things simple and generic and leave this sort of
simplification for the cleanup/simplification phase.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 linearize.c                                  | 6 ------
 validation/linear/degen-function.c           | 6 +++---
 validation/{linear => optim}/inline-return.c | 4 ++--
 3 files changed, 5 insertions(+), 11 deletions(-)
 rename validation/{linear => optim}/inline-return.c (67%)

diff --git a/linearize.c b/linearize.c
index 4e373f3f9..54cdf116f 100644
--- a/linearize.c
+++ b/linearize.c
@@ -1731,12 +1731,6 @@ static pseudo_t linearize_compound_statement(struct entrypoint *ep, struct state
 
 		if (!phi_node)
 			return pseudo;
-
-		if (pseudo_list_size(phi_node->phi_list)==1) {
-			pseudo = first_pseudo(phi_node->phi_list);
-			assert(pseudo->type == PSEUDO_PHI);
-			return pseudo->def->src1;
-		}
 		return phi_node->target;
 	}
 
diff --git a/validation/linear/degen-function.c b/validation/linear/degen-function.c
index 4fb2d5645..a7cff443c 100644
--- a/validation/linear/degen-function.c
+++ b/validation/linear/degen-function.c
@@ -20,7 +20,7 @@ fa:
 
 .L1:
 	phi.64      %r2 <- %phi1(return)
-	ret.64      %r1
+	ret.64      %r2
 
 
 f0:
@@ -32,7 +32,7 @@ f0:
 
 .L3:
 	phi.64      %r4 <- %phi2(return)
-	ret.64      %r3
+	ret.64      %r4
 
 
 f1:
@@ -44,7 +44,7 @@ f1:
 
 .L5:
 	phi.64      %r6 <- %phi3(return)
-	ret.64      %r5
+	ret.64      %r6
 
 
  * check-output-end
diff --git a/validation/linear/inline-return.c b/validation/optim/inline-return.c
similarity index 67%
rename from validation/linear/inline-return.c
rename to validation/optim/inline-return.c
index b1e4d8446..d075715d6 100644
--- a/validation/linear/inline-return.c
+++ b/validation/optim/inline-return.c
@@ -16,9 +16,9 @@ int bar(void)
 
 /*
  * check-name: inline-return.c
- * check-command: test-linearize -fdump-ir=linearize -Wno-decl $file
+ * check-command: test-linearize -Wno-decl $file
  *
  * check-output-ignore
- * check-output-contains: ret\\..*\\$1
+ * check-output-pattern(2): ret\\..*\\$1
  * check-output-excludes: ret\\..*\\$0
  */
-- 
2.16.2

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux