The field struct instruction:symbol is only used by OP_SYMADDRs and is aliased to :src/src1. IN fact OP_SYMADDR is very much an unop and using :src for it instead of :symbol allow to use it as such and thus to remove some redundant code. Rename insn->symbol to insn->src, remove the now unneeded definition of this field and shuffle some code around to make clear that OP_SYMADDRs are unops. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- Documentation/IR.rst | 12 ++++++------ cse.c | 11 ++--------- linearize.c | 8 ++------ linearize.h | 5 +---- liveness.c | 5 +---- simplify.c | 6 +++--- 6 files changed, 15 insertions(+), 32 deletions(-) diff --git a/Documentation/IR.rst b/Documentation/IR.rst index 67ef06a5d..45bb774b0 100644 --- a/Documentation/IR.rst +++ b/Documentation/IR.rst @@ -249,6 +249,12 @@ Unary ops * .target: result of the operation (must be a floating-point type) * .type: type of .target +.. op:: OP_SYMADDR + Create a pseudo corresponding to the address of a symbol. + + * .src: input symbol (must be a PSEUDO_SYM) + * .target: symbol's address + .. op:: OP_COPY Copy (only needed after out-of-SSA). @@ -311,12 +317,6 @@ Memory ops Others ------ -.. op:: OP_SYMADDR - Create a pseudo corresponding to the address of a symbol. - - * .symbol: (pseudo_t) input symbol (alias .src) - * .target: symbol's address - .. op:: OP_SETFVAL Create a pseudo corresponding to a floating-point literal. diff --git a/cse.c b/cse.c index 79d37cfd1..6e521f12b 100644 --- a/cse.c +++ b/cse.c @@ -76,6 +76,7 @@ void cse_collect(struct instruction *insn) /* Unary */ case OP_NOT: case OP_NEG: case OP_FNEG: + case OP_SYMADDR: hash += hashval(insn->src1); break; @@ -87,10 +88,6 @@ void cse_collect(struct instruction *insn) hash += hashval(insn->fvalue); break; - case OP_SYMADDR: - hash += hashval(insn->symbol); - break; - case OP_CAST: case OP_SCAST: case OP_PTRCAST: @@ -214,15 +211,11 @@ static int insn_compare(const void *_i1, const void *_i2) /* Unary */ case OP_NOT: case OP_NEG: case OP_FNEG: + case OP_SYMADDR: if (i1->src1 != i2->src1) return i1->src1 < i2->src1 ? -1 : 1; break; - case OP_SYMADDR: - if (i1->symbol != i2->symbol) - return i1->symbol < i2->symbol ? -1 : 1; - break; - case OP_SETVAL: if (i1->val != i2->val) return i1->val < i2->val ? -1 : 1; diff --git a/linearize.c b/linearize.c index 6284d079b..e9354e437 100644 --- a/linearize.c +++ b/linearize.c @@ -343,11 +343,6 @@ const char *show_instruction(struct instruction *insn) buf += sprintf(buf, "%s", show_label(insn->bb_true)); break; - case OP_SYMADDR: - buf += sprintf(buf, "%s <- ", show_pseudo(insn->target)); - buf += sprintf(buf, "%s", show_pseudo(insn->symbol)); - break; - case OP_SETVAL: { struct expression *expr = insn->val; buf += sprintf(buf, "%s <- ", show_pseudo(insn->target)); @@ -469,6 +464,7 @@ const char *show_instruction(struct instruction *insn) case OP_NOT: case OP_NEG: case OP_FNEG: + case OP_SYMADDR: buf += sprintf(buf, "%s <- %s", show_pseudo(insn->target), show_pseudo(insn->src1)); break; @@ -1028,7 +1024,7 @@ static pseudo_t add_symbol_address(struct entrypoint *ep, struct symbol *sym) pseudo_t target = alloc_pseudo(insn); insn->target = target; - use_pseudo(insn, symbol_pseudo(ep, sym), &insn->symbol); + use_pseudo(insn, symbol_pseudo(ep, sym), &insn->src); add_one_insn(ep, insn); return target; } diff --git a/linearize.h b/linearize.h index db4a67f3d..da2c6806d 100644 --- a/linearize.h +++ b/linearize.h @@ -117,9 +117,6 @@ struct instruction { pseudo_t base; unsigned from, len; }; - struct /* symaddr */ { - pseudo_t symbol; /* Subtle: same offset as "src" !! */ - }; struct /* setval */ { struct expression *val; }; @@ -218,6 +215,7 @@ enum opcode { OP_NOT, OP_NEG, OP_FNEG, + OP_SYMADDR, /* Select - three input values */ OP_SEL, @@ -227,7 +225,6 @@ enum opcode { OP_STORE, OP_SETVAL, OP_SETFVAL, - OP_SYMADDR, /* Other */ OP_PHI, diff --git a/liveness.c b/liveness.c index e0e583292..d51e52132 100644 --- a/liveness.c +++ b/liveness.c @@ -72,6 +72,7 @@ static void track_instruction_usage(struct basic_block *bb, struct instruction * /* Uni */ case OP_NOT: case OP_NEG: case OP_FNEG: + case OP_SYMADDR: USES(src1); DEFINES(target); break; @@ -93,10 +94,6 @@ static void track_instruction_usage(struct basic_block *bb, struct instruction * DEFINES(target); break; - case OP_SYMADDR: - USES(symbol); DEFINES(target); - break; - /* Other */ case OP_PHI: /* Phi-nodes are "backwards" nodes. Their def doesn't matter */ diff --git a/simplify.c b/simplify.c index be7208608..aab98b2bc 100644 --- a/simplify.c +++ b/simplify.c @@ -269,7 +269,7 @@ int kill_insn(struct instruction *insn, int force) break; case OP_SYMADDR: - kill_use(&insn->symbol); + kill_use(&insn->src); repeat_phase |= REPEAT_SYMBOL_CLEANUP; break; @@ -1218,9 +1218,9 @@ int simplify_instruction(struct instruction *insn) case OP_STORE: return simplify_memop(insn); case OP_SYMADDR: - if (dead_insn(insn, &insn->symbol, NULL, NULL)) + if (dead_insn(insn, &insn->src, NULL, NULL)) return REPEAT_CSE | REPEAT_SYMBOL_CLEANUP; - return replace_with_pseudo(insn, insn->symbol); + return replace_with_pseudo(insn, insn->src); case OP_CAST: case OP_SCAST: case OP_FPCAST: -- 2.17.1 -- 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