aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-04-09 14:44:37 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-04-10 15:51:11 +0200
commit75c5952aece63d5c90b2adfeaff4cb77e3a47520 (patch)
treebf9e9ff666ee98614e1659a574e82f8320715f73
parent2cd6d34e815a7442b0b113f395504131b3a92e77 (diff)
downloadsparse-75c5952aece63d5c90b2adfeaff4cb77e3a47520.tar.gz
linear: only allocate call instructions when needed
When linearizing a call expression, the corresponding instruction is allocated very early: - before the valdity are done - before the linearization is handled to one of the specific methods In both case it means that the allocated instruction is not used. Fix this by doing the allocation only once it's needed. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--linearize.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/linearize.c b/linearize.c
index 7248fa56..cf87545c 100644
--- a/linearize.c
+++ b/linearize.c
@@ -1533,7 +1533,7 @@ static pseudo_t linearize_assignment(struct entrypoint *ep, struct expression *e
static pseudo_t linearize_call_expression(struct entrypoint *ep, struct expression *expr)
{
struct expression *arg, *fn;
- struct instruction *insn = alloc_typed_instruction(OP_CALL, expr->ctype);
+ struct instruction *insn;
pseudo_t retval, call;
struct ctype *ctype = NULL;
struct symbol *fntype;
@@ -1554,6 +1554,7 @@ static pseudo_t linearize_call_expression(struct entrypoint *ep, struct expressi
ctype = &fntype->ctype;
+ insn = alloc_typed_instruction(OP_CALL, expr->ctype);
add_symbol(&insn->fntypes, fntype);
FOR_EACH_PTR(expr->args, arg) {
pseudo_t new = linearize_expression(ep, arg);