Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Change
aptos move coverage
to work better for red-black-map test case.Currently includes voluminous debugging output to help resolve remaining iussues.
Also adds
--show-locs
flag toaptos move disassemble
command to allow showinglocations for compiler debugging (in a somewhat hard-to use form, unfortunately).
Also add more logging of
Loc
information ifMVC_LOG=debug
to facilitate debuggingof remaining location tracking probems.
Details of changes to
aptos move coverage
to work better for red-black-map test case:and try to more carefully handle inlined code. Notably, when
computing coverage for a module, we search for code in other modules
that may correspond to this module (due to inlining). To better
handle instructions with imprecise code attribution, we consider
the source corresponding to an instruction to be the minimal source
set which doesn't overlap others.
How Has This Been Tested?
Run in a code directory, with a source module such as such as
red_black_map
in a file with the same name:The three output files may be useful:
test.out
shows the compile debug log. Note that we are disabling peephole optimizations to avoid complication here.coverage.out
shows the newly corrected test coverage output, which is correct w.r.t. the code attributions,but those are incorrect. There is currently a lot of extra debugigng output, so you will want to skip to the end
of the file and scroll backwards (using
less -R coverage.out
to see colors)build/RedBlackMap/bytecode_modules/red_black_map.mv.asm
shows the code attribution asfile_hash8:offset1-offset2
at the end of each instruction, using offsets from beginning of the source file.
Key Areas to Review
The coverage output looks reasonable, but the assembly listing showing
locs reveals that there is a problem with bytecode attribution to
source code.
Notably, if you look at the
red_black_map.mv.asm
output, the basic blockwhich corresponds to source code around line 90-92 is clearly misattributed.
The source code in
red_black_map.move
is the final 3 lines shown here (the first line is a call which is inlined):These lines are at lines 90-92, character offset
2769-2921
, inred_black_map.move
.The corresponding code can be found in the assembly code by searching
for
PackVariant
calls forColor/Black
andColor/Red
in closesuccession in the same block, followed by a
Ret
. I see it as blockB34
in my listing:Including an extra line or two of context, as shown here, reveals that the locations are at least
off by one line, as the line at the end of each block seems to have the same location as the beginning
of the following block. In fact the problem is worse than this, as the locations here are nowhere
near the positions
2769-2921
of the corresponding source code.We find these locations applied to some quite offset code, shown here:
Referring to the file
test.out
generated above, we can look at the corresponding lines in thestackless bytecode. Search from the bottom of that file for the regexp "
# at .*red_black_map.move:90
",e.g., using
less
, and scroll up a bit to see the related code. We find the following code:Note that the attributes precede each line. Here we see that the stackless bytecode
is better attributed to the original source code, except that:
code
So we have 2 problems:
code they are labeling
Final code generation occurs in
third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs
, andI've added more debugging output to start to try to understand what's going on,
(search for "
Generating code for bytecode
" and "setting location for
" intest.out
)but it's still not clear why the code is getting the wrong locations.
Not related to Peephole
With peephole opts off:
Type of Change
Which Components or Systems Does This Change Impact?
Checklist