5 ms·
> It's literally undecidable in principle whether some assembler correctly restores some register R. No, it's literally undecidable in principle whether every
by twic 4y ago
> It's literally undecidable in principle whether some assembler correctly restores some register R.
No, it's literally undecidable in principle whether every bit of assembler correctly restores some register R. For any given bit of inline assembler, it's quite likely to be trivial.
In any case, we can have a useful safety feature without requiring the compiler to decide. The compiler can easily work out all the registers which get written to (right?), just not which get restored. So in addition to the clobber list, we could have a list of registers which the programmer asserts that the code restores. A register which is written to has to be on either the clobber list or the restore list (or be an output). This certainly isn't foolproof, but it would catch accidental clobbers.
- Animats 4y ago> No, it's literally undecidable in principle whether every bit of assembler correctly restores some register R. For any given bit of inline assembler, it's quite likely to be trivial. Exactly. And if it's non-trivial to decide something that basic, you're doing it wrong. Saving and restoring all the registers is always an option. Only saving and restoring some of them is an optimization which must be shown to be sound.
- tialaramex 4y ago> every bit of assembler correctly restores some register R. Thanks, I was trying to think about the correct way to express this but clearly I didn't do the best job.