This is an archive of the discontinued LLVM Phabricator instance.

Introduce the llvm-cfi-verify tool.
ClosedPublic

Authored by hctim on Sep 15 2017, 2:58 PM.

Details

Summary

Introduces the llvm-cfi-verify tool to llvm. Includes the design document (docs/CFIVerify.rst). Current implementation of the tool is simply a disassembler that identifies and prints the indirect control flow instructions.

Event Timeline

hctim created this revision.Sep 15 2017, 2:58 PM
docs/CFIVerify.rst
38

ensures

56

nit: bytecode is traditionally used to refer to instructions run by a VM/interpreter, replace with 'machine code' instead

tools/llvm-cfi-verify/llvm-cfi-verify.cpp
2

Run clang-format

213

errs()

236

This can assert() on a bad opcode, should we check if (BadInstruction) before this?

244

I believe you can use a range-based for loop here: for (auto &Op : Instruction)

hctim updated this revision to Diff 115737.Sep 18 2017, 3:40 PM
hctim marked 6 inline comments as done.

Updates from Vlad's comments.

tools/llvm-cfi-verify/llvm-cfi-verify.cpp
244

Thanks for the catch, had a look at the source for a range-iterator from ::Operands.begin() to ::Operands.end() under the name "operands()" but didn't realise that they were simply under the object itself.

tools/llvm-cfi-verify/llvm-cfi-verify.cpp
154

Could we change these messages to 'Failed to initialize MCRegisterInfo' instead?

kcc added inline comments.Sep 18 2017, 5:37 PM
docs/CFIVerify.rst
66

I thought the call should always be fallthrough. Did you see the opposite case?

hctim updated this revision to Diff 115896.Sep 19 2017, 1:42 PM
hctim marked 2 inline comments as done.

Changed error reporting text slightly. Single line if-else statements now no longer have braces. Utilised commit in D37719 to remove helper function for Triple deduction from an ObjectFile.

hctim added inline comments.Sep 19 2017, 1:42 PM
docs/CFIVerify.rst
66

Fallthrough-to-ud2 is currently present. Will write some code to evaluate this case and provide report.

vlad.tsyrklevich accepted this revision.Sep 19 2017, 3:03 PM
This revision is now accepted and ready to land.Sep 19 2017, 3:03 PM
This revision was automatically updated to reflect the committed changes.