aboutsummaryrefslogtreecommitdiffhomepage
path: root/ir/simpl.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-02-18 18:17:14 +0100
committerlemon <lsof@mailbox.org>2026-02-18 18:19:11 +0100
commit0b90de2e773f439fa606ddf2bc403d2f42fa4c3d (patch)
tree2b7b6600d8bbbe08735c1f2d6d3e6b2885c0e5e0 /ir/simpl.c
parent886fdfe8c856ee778103661b832b28cf3e6aed7e (diff)
ir: basic inlining pass implementation
Diffstat (limited to 'ir/simpl.c')
-rw-r--r--ir/simpl.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/ir/simpl.c b/ir/simpl.c
index c52f809..a01879a 100644
--- a/ir/simpl.c
+++ b/ir/simpl.c
@@ -82,7 +82,7 @@ divmodk(struct instr *ins, struct block *blk, int *curi)
}
static int
-ins(struct instr *ins, struct block *blk, int *curi)
+doins(struct instr *ins, struct block *blk, int *curi)
{
int narg = opnarg[ins->op];
if (oisarith(ins->op)) {
@@ -257,7 +257,11 @@ simpl(struct function *fn)
int curi = 0;
DoIns:
for (; curi < blk->ins.n; ++curi) {
- inschange += ins(&instrtab[blk->ins.p[curi]], blk, &curi);
+ struct instr *ins = &instrtab[blk->ins.p[curi]];
+ if (ins->op != Onop) {
+ if (!(fn->prop & FNUSE)) filluses(fn);
+ inschange += doins(ins, blk, &curi);
+ }
}
if (blk->s2 && isintcon(blk->jmp.arg[0])) {
@@ -272,8 +276,9 @@ simpl(struct function *fn)
}
}
- /* thread jumps.. */
- if (!blk->phi.n && !blk->ins.n) {
+ if (blk != fn->entry && blk->npred == 0) {
+ freeblk(fn, blk);
+ } else if (!blk->phi.n && !blk->ins.n) { /* thread jumps.. */
if (blk->jmp.t == Jb && !blk->s2) {
jmpfind(jmpfinal, &blk->s1);
if (blk->s1 != blk) {