[PATCH] fix accesses through incorrect union members

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

 



No functional change - ->src1 and ->phi_src are at the same offset and have
the same type.
Discovered and debugged by compiling with "-Dunion=struct" in CFLAGS, which
I originally did because I wanted to easily see in GDB which union fields
I'm supposed to be accessing. Amazingly, running with -Dunion=struct seems
to work pretty well if you patch dup_token() to copy all the union members.

Signed-off-by: Jann Horn <jannh@xxxxxxxxxx>
---
 flow.c     |  4 ++--
 simplify.c | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/flow.c b/flow.c
index 6b2c879..5a4ae5e 100644
--- a/flow.c
+++ b/flow.c
@@ -434,9 +434,9 @@ void rewrite_load_instruction(struct instruction *insn, struct pseudo_list *domi
 	 * Check for somewhat common case of duplicate
 	 * phi nodes.
 	 */
-	new = first_pseudo(dominators)->def->src1;
+	new = first_pseudo(dominators)->def->phi_src;
 	FOR_EACH_PTR(dominators, phi) {
-		if (new != phi->def->src1)
+		if (new != phi->def->phi_src)
 			goto complex_phi;
 		new->ident = new->ident ? : phi->ident;
 	} END_FOR_EACH_PTR(phi);
diff --git a/simplify.c b/simplify.c
index 2bc86f5..5f9eb30 100644
--- a/simplify.c
+++ b/simplify.c
@@ -68,9 +68,9 @@ static int if_convert_phi(struct instruction *insn)
 		return 0;
 	if (linearize_ptr_list((struct ptr_list *)bb->parents, (void **)parents, 3) != 2)
 		return 0;
-	p1 = array[0]->src1;
+	p1 = array[0]->phi_src;
 	bb1 = array[0]->bb;
-	p2 = array[1]->src1;
+	p2 = array[1]->phi_src;
 	bb2 = array[1]->bb;
 
 	/* Only try the simple "direct parents" case */
@@ -146,10 +146,10 @@ static int clean_up_phi(struct instruction *insn)
 		if (phi == VOID)
 			continue;
 		def = phi->def;
-		if (def->src1 == VOID || !def->bb)
+		if (def->phi_src == VOID || !def->bb)
 			continue;
 		if (last) {
-			if (last->src1 != def->src1)
+			if (last->phi_src != def->phi_src)
 				same = 0;
 			continue;
 		}
@@ -157,7 +157,7 @@ static int clean_up_phi(struct instruction *insn)
 	} END_FOR_EACH_PTR(phi);
 
 	if (same) {
-		pseudo_t pseudo = last ? last->src1 : VOID;
+		pseudo_t pseudo = last ? last->phi_src : VOID;
 		convert_instruction_target(insn, pseudo);
 		kill_instruction(insn);
 		return REPEAT_CSE;
-- 
2.16.1.291.g4437f3f132-goog

--
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