[AArch64] Q/GE flags not saved/restored in drreg
Today on AArch64, drreg uses mrs
and msr
to read and write aflags respectively via DR_REG_NZCV
. This leaves out the Q (saturation) and GE (greater-or-equal) flags, which are considered a part of aflags by DR.
https://github.com/DynamoRIO/dynamorio/blob/e8fc651f485f858127bf2394defc382d5cdff641/core/ir/instr_api.h#L2433
This causes issues with liveness analysis, which thinks that aflags are always live, and therefore always stores them to a slot in drreg_reserve_aflags
. So, this optimisation is never invoked: https://github.com/DynamoRIO/dynamorio/blob/e8fc651f485f858127bf2394defc382d5cdff641/ext/drreg/drreg.c#L1616
We should either start saving/restoring Q and GE flags too, or if they are not required, skip them from liveness analysis to avoid the extra aflags spills/restores in drreg.
To read/write the Q flag, we may have to use FPSR: https://developer.arm.com/documentation/100076/0100/instruction-set-overview/overview-of-aarch64-state/the-q-flag-in-aarch64-state
I couldn't find any documentation yet for the GE flag. Though DR does have it in code: https://github.com/DynamoRIO/dynamorio/blob/e8fc651f485f858127bf2394defc382d5cdff641/core/ir/instr_api.h#L2443