diffkemp icon indicating copy to clipboard operation
diffkemp copied to clipboard

Cannot handle combination of relocations and moving code to a separate function

Open TomasKucma opened this issue 1 year ago • 0 comments

If a semantic preserving change consists of moving a section of code into a separate function and replacing the section with a call to the function, and at the same time, relocating the call further in the code (while not breaking any data dependencies), DiffKemp is unable to detect the semantic equivalence. When comparing the first instruction of the original relocated section and failing, DiffKemp will try to look for relocation, but cannot find it, as it has been replaced with a function call. However, the function call also won't be inlined, because it occurs further than the first failed compared instruction, and so the whole comparison fails.

When looking for relocation, the function call will be temporarily placed into the tryInline field of ModuleComparator. However, after relocation matching fails, the field is reset to the previous value using tryInlineBackup of DifferentialFunctionComparator.

If the back-up wouldn't loaded into the tryInline field after failed relocation matching, at least in cases where back-up contained no functions to inline, it may possibly solve this problem, at some performance cost, by ensuring even the calls further within the block are inlined, if possible.

Should be reproducible with this linux kernel commit - https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git/commit/?id=089221d3457b8756d6823be9857884d938af817c

TomasKucma avatar Feb 22 '24 17:02 TomasKucma