aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--Documentation/IR.rst2
-rw-r--r--evaluate.c3
-rw-r--r--expression.h2
-rw-r--r--linearize.c6
-rw-r--r--linearize.h9
-rw-r--r--liveness.c7
-rw-r--r--pre-process.c6
-rw-r--r--show-parse.c2
-rw-r--r--validation/eval/assign-restricted-ok.c22
-rw-r--r--validation/linear/asm-out0.c2
10 files changed, 41 insertions, 20 deletions
diff --git a/Documentation/IR.rst b/Documentation/IR.rst
index 38df84ff..e1613402 100644
--- a/Documentation/IR.rst
+++ b/Documentation/IR.rst
@@ -408,7 +408,7 @@ Others
Extract a "slice" from an aggregate.
* .base: (pseudo_t) aggregate (alias .src)
- * .from, .len: offet & size of the "slice" within the aggregate
+ * .from: offset of the "slice" within the aggregate
* .target: result
* .type: type of .target
diff --git a/evaluate.c b/evaluate.c
index 41871e18..eea6b7ad 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -1442,7 +1442,7 @@ static int check_assignment_types(struct symbol *target, struct expression **rp,
if (sclass & TYPE_FOULED && unfoul(s) == t)
goto Cast;
if (!restricted_value(*rp, target))
- return 1;
+ goto Cast;
if (s == t)
return 1;
} else if (!(sclass & TYPE_RESTRICT))
@@ -2170,7 +2170,6 @@ static struct symbol *evaluate_member_dereference(struct expression *expr)
}
expr->r_bitpos += bytes_to_bits(offset);
expr->type = EXPR_SLICE;
- expr->r_nrbits = member->bit_size;
expr->r_bitpos += member->bit_offset;
expr->ctype = member;
return member;
diff --git a/expression.h b/expression.h
index 3e9e9d85..f733c076 100644
--- a/expression.h
+++ b/expression.h
@@ -206,7 +206,7 @@ struct expression {
// EXPR_SLICE
struct /* slice */ {
struct expression *base;
- unsigned r_bitpos, r_nrbits;
+ unsigned r_bitpos;
};
// EXPR_CAST, EXPR_FORCE_CAST, EXPR_IMPLIED_CAST,
// EXPR_SIZEOF, EXPR_ALIGNOF and EXPR_PTRSIZEOF
diff --git a/linearize.c b/linearize.c
index 0c9b0e59..b06c0625 100644
--- a/linearize.c
+++ b/linearize.c
@@ -470,7 +470,7 @@ const char *show_instruction(struct instruction *insn)
break;
case OP_SLICE:
- buf += sprintf(buf, "%s <- %s, %d, %d", show_pseudo(insn->target), show_pseudo(insn->base), insn->from, insn->len);
+ buf += sprintf(buf, "%s <- (%d) %s, %d", show_pseudo(insn->target), type_size(insn->orig_type), show_pseudo(insn->src), insn->from);
break;
case OP_NOT: case OP_NEG:
@@ -1239,8 +1239,8 @@ static pseudo_t linearize_slice(struct entrypoint *ep, struct expression *expr)
insn->target = new;
insn->from = expr->r_bitpos;
- insn->len = expr->r_nrbits;
- use_pseudo(insn, pre, &insn->base);
+ insn->orig_type = expr->base->ctype;
+ use_pseudo(insn, pre, &insn->src);
add_one_insn(ep, insn);
return new;
}
diff --git a/linearize.h b/linearize.h
index cf0cf066..17e8c38a 100644
--- a/linearize.h
+++ b/linearize.h
@@ -113,6 +113,7 @@ struct instruction {
};
struct /* unops */ {
pseudo_t src;
+ unsigned from; /* slice */
struct symbol *orig_type; /* casts */
};
struct /* memops */ {
@@ -127,10 +128,6 @@ struct instruction {
pseudo_t _src1, _src2; // alias .src[12]
struct symbol *itype; // input operands' type
};
- struct /* slice */ {
- pseudo_t base;
- unsigned from, len;
- };
struct /* setval */ {
struct expression *val;
};
@@ -150,8 +147,8 @@ struct instruction {
struct /* asm */ {
const char *string;
struct asm_rules *asm_rules;
- int clobber_memory:1;
- int output_memory:1;
+ unsigned int clobber_memory:1;
+ unsigned int output_memory:1;
};
};
};
diff --git a/liveness.c b/liveness.c
index 30a9a5b6..5b10e5e1 100644
--- a/liveness.c
+++ b/liveness.c
@@ -76,7 +76,8 @@ static void track_instruction_usage(struct basic_block *bb, struct instruction *
/* Uni */
case OP_UNOP ... OP_UNOP_END:
case OP_SYMADDR:
- USES(src1); DEFINES(target);
+ case OP_SLICE:
+ USES(src); DEFINES(target);
break;
case OP_SEL:
@@ -121,10 +122,6 @@ static void track_instruction_usage(struct basic_block *bb, struct instruction *
} END_FOR_EACH_PTR(pseudo);
break;
- case OP_SLICE:
- USES(base); DEFINES(target);
- break;
-
case OP_ASM:
asm_liveness(bb, insn, def, use);
break;
diff --git a/pre-process.c b/pre-process.c
index 7a1478f6..3fb25082 100644
--- a/pre-process.c
+++ b/pre-process.c
@@ -884,6 +884,12 @@ static void set_stream_include_path(struct stream *stream)
memcpy(m, stream->name, len);
m[len] = 0;
path = m;
+ /* normalize this path */
+ while (path[0] == '.' && path[1] == '/') {
+ path += 2;
+ while (path[0] == '/')
+ path++;
+ }
}
stream->path = path;
}
diff --git a/show-parse.c b/show-parse.c
index 3ab8ec8f..e2fc18bb 100644
--- a/show-parse.c
+++ b/show-parse.c
@@ -819,7 +819,7 @@ static int show_slice(struct expression *expr)
{
int target = show_expression(expr->base);
int new = new_pseudo();
- printf("\tslice.%d\t\tv%d,v%d,%d\n", expr->r_nrbits, target, new, expr->r_bitpos);
+ printf("\tslice.%d\t\tv%d,v%d,%d\n", expr->ctype->bit_size, target, new, expr->r_bitpos);
return new;
}
diff --git a/validation/eval/assign-restricted-ok.c b/validation/eval/assign-restricted-ok.c
new file mode 100644
index 00000000..df94d8c9
--- /dev/null
+++ b/validation/eval/assign-restricted-ok.c
@@ -0,0 +1,22 @@
+#ifdef __CHECKER__
+#define __bitwise __attribute__((bitwise))
+#else
+#define __bitwise
+#endif
+
+typedef __INT16_TYPE__ __bitwise __be16;
+
+static __be16 foo(void)
+{
+ __be16 val = 0;
+ return val;
+}
+
+/*
+ * check-name: assign-restricted-ok
+ * check-command: test-linearize -fdump-ir $file
+ *
+ * check-output-ignore
+ * check-output-contains: store\\.16
+ * check-output-excludes: store\\.32
+ */
diff --git a/validation/linear/asm-out0.c b/validation/linear/asm-out0.c
index a8e0be69..8b0907b3 100644
--- a/validation/linear/asm-out0.c
+++ b/validation/linear/asm-out0.c
@@ -6,7 +6,7 @@ static void asm_out0(void)
/*
* check-name: asm-out0
- * check-command: test-linearize -fdump-ir $file
+ * check-command: test-linearize -m64 -fdump-ir $file
*
* check-output-start
asm_out0: