Opaque Pointers Lead to Incorrect Register Sizes by Pulling a Type from `getResultElementType` for a Register that is not in the Operand Cache but is Declared as a Variable in the Lifted Function #618
This issue is exacerbated by #615 since instructions get individual lifters to lift themselves, not sharing a cache (this probably should be addressed somehow, but cache consistency becomes tricky), causing register cache misses to occur more frequently. If we have a cache miss for lifting a register operand that is, however, found in the function as a GEP we pull a type from getResultElementType but this type does not match the desired type for the register. For instance, if we GEP a 32 bit register W0 then call getResultElementType on the GEP we are going to get a 64 bit type because of the size of the underlying field in the state structure. This line https://github.com/lifting-bits/remill/blob/c0f90b9e4a251615288ed4b65ead81cea617da8c/lib/BC/Util.cpp#L220 will not pull the correct type, we need to source the type info from the Arch's knowledge about the reg name being asked for and not from the state structure.
This issue is exacerbated by #615 since instructions get individual lifters to lift themselves, not sharing a cache (this probably should be addressed somehow, but cache consistency becomes tricky), causing register cache misses to occur more frequently. If we have a cache miss for lifting a register operand that is, however, found in the function as a GEP we pull a type from getResultElementType but this type does not match the desired type for the register. For instance, if we GEP a 32 bit register W0 then call getResultElementType on the GEP we are going to get a 64 bit type because of the size of the underlying field in the state structure. This line https://github.com/lifting-bits/remill/blob/c0f90b9e4a251615288ed4b65ead81cea617da8c/lib/BC/Util.cpp#L220 will not pull the correct type, we need to source the type info from the Arch's knowledge about the reg name being asked for and not from the state structure.
Regression test here: https://github.com/lifting-bits/remill/blob/c829715b95a69401a0f439b8004962a3dda6e803/tests/Thumb/TestLifting.cpp#L236
This test fails on the second check because the variable finding code returns a 64 bit size type for W0 on the second call.