aboutsummaryrefslogtreecommitdiff
path: root/src/regalloc.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-04-15 03:08:34 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-04-15 03:37:10 +0300
commit78d992ff3052db9dc98a3074e8a4423760c342f1 (patch)
tree12945a143e462cefccdca8dd589d3f9122833d4e /src/regalloc.c
parent5a728ae106b978c6de0fa6316f37eb3b4a86a405 (diff)
downloadqbt-78d992ff3052db9dc98a3074e8a4423760c342f1.tar.gz
qbt-78d992ff3052db9dc98a3074e8a4423760c342f1.zip
fix insert_before/after
+ Hopefully for good, quite a lot of messing about with those functions
Diffstat (limited to 'src/regalloc.c')
-rw-r--r--src/regalloc.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/regalloc.c b/src/regalloc.c
index 8c42eab..cd21f5e 100644
--- a/src/regalloc.c
+++ b/src/regalloc.c
@@ -401,15 +401,24 @@ static void insn_insert_before_call(struct blk *b, struct insn save,
{
assert((insn_at(b->insns, pos)).type == CALL);
struct insn setup;
- do {
- if (pos < 0)
+ while (1) {
+ if (pos < 0) {
+ pos = 0;
break;
+ }
setup = insn_at(b->insns, pos);
- pos--;
- } while (has_insn_flag(setup, CALL_SETUP));
+ if (has_insn_flag(setup, CALL_SETUP)) {
+ pos--;
+ continue;
+ }
+
+ /* we want to insert after this instruction */
+ pos++;
+ break;
+ };
- insn_insert(b, save, pos + 1);
+ insn_insert(b, save, pos);
}
static void insn_insert_after_call(struct blk *b, struct insn restore,
@@ -419,13 +428,18 @@ static void insn_insert_after_call(struct blk *b, struct insn restore,
size_t max = vec_len(&b->insns);
struct insn setup;
- do {
+ while (1) {
if (pos == max)
break;
setup = insn_at(b->insns, pos);
- pos++;
- } while (has_insn_flag(setup, CALL_TEARDOWN));
+ if (has_insn_flag(setup, CALL_TEARDOWN)) {
+ pos++;
+ continue;
+ }
+
+ break;
+ }
insn_insert(b, restore, pos);
}