This is an archive of the discontinued LLVM Phabricator instance.

Check Compile Flow Consistency tool (check_cfc.py)
ClosedPublic

Authored by russell.gallop on Mar 31 2015, 9:07 AM.

Details

Summary

This is a tool for checking consistency of code generation with different compiler options (such as -g or outputting to .s). This tool has been used internally to Sony Computer Entertainment for a while. It has found a number of code generation issues (PR18590, 19051, 21807, 22854, 22947 and 22955). As such I thought that this would be beneficial to send upstream and I am presenting a lightning talk and poster about this at Euro LLVM.

The script is very simple. It acts as a wrapper to clang or clang++ but performs 2 (or more) compiles then compares the object files. Instructions for use are in check_cfc.py including how to use with LNT.

This works via the clang driver so I assume that it should live in cfe/trunk/utils (even though it tends to find issues in LLVM). Let me know if this is correct.

Russell Gallop
SN Systems - Sony Computer Entertainment Group

Diff Detail

Event Timeline

russell.gallop retitled this revision from to Check Compile Flow Consistency tool (check_cfc.py).
russell.gallop updated this object.
russell.gallop edited the test plan for this revision. (Show Details)
russell.gallop added a subscriber: Unknown Object (MLST).
rafael added inline comments.Mar 31 2015, 10:14 AM
utils/check_cfc/check_cfc.py
275

For this you can use clang's -via-asm-file. That way you don't have to worry about -mrelax-all.

Use -via-file-asm for dash_s_no_change check.

Fix line endings.

rafael added inline comments.Apr 1 2015, 7:43 AM
utils/check_cfc/check_cfc.py
87

Would it be more idiomatic to use filter?

105

This is just get_output_file != None, no?

250

This could be a bit more strict. For example, data sections should also not change.

How about comparing all sections that are present in both files?

267

You can be more strict in here. The two objects should be byte by byte identical.

russell.gallop added inline comments.Apr 1 2015, 9:57 AM
utils/check_cfc/check_cfc.py
87

I think that depends who you ask. Google style guide prefers list comprehensions.

I've tried the filter and I think it looks clearer so I'll change it.

105

Not quite, as get_output_file() derives something from the input file if there is no -o.

However I can see that there's some duplication here so I've refactored it so this can be done and it saves some code.

250

That's a good idea. I think that the obj_diff needs to provide different kinds of comparison (code, data, debug, byte for byte etc.) that a check can choose between.

Are you happy for me to treat this as an enhancement and I'll work out the best way to do this?

Fixes for points raised by Rafael.

Have not changed the comparisons. Is it okay to leave this for an follow-up patch?

rnk added a subscriber: rnk.Apr 1 2015, 10:58 AM

Thanks, this seems like a great tool. :)

rafael accepted this revision.Apr 1 2015, 11:55 AM
rafael edited edge metadata.

Other than the style comment I think this is fine.

We should probably grow more specialized object comparisons, but yes, that can be done afterwards.

utils/check_cfc/check_cfc.py
300

80 columns ?

This revision is now accepted and ready to land.Apr 1 2015, 11:55 AM
This revision was automatically updated to reflect the committed changes.

Thanks Rafael. I've fixed the 80 col violations and committed revision 233919.