This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Add an option to enable LLVM IR linting
AbandonedPublic

Authored by vsk on Mar 14 2017, 11:34 AM.

Details

Summary

LLVM has a nifty linter which checks for some common kinds of unusual or
undefined behavior by doing some basic IR-level static analysis.

Add a CC1 option to clang which enables this analysis.

Having the linter available through clang could be a useful debugging
tool. It can also be a useful reporting tool: hacking your build system
to add in "-Xclang -enable-llvm-linter" is usually easier than hacking
it to add "$CC ... | opt -S -o /dev/null -lint".

Eventually, I'd like to teach the linter about the sanitizers, so that
it can statically report the kinds of bugs the sanitizers know how to
flag. This would work by checking for diagnostic calls which post-dom
function entry blocks (unconditionally buggy code). The research paper
on the STACK static UB checker suggests that this could be useful.

Diff Detail

Event Timeline

vsk created this revision.Mar 14 2017, 11:34 AM
vsk abandoned this revision.May 11 2017, 11:39 AM

I'll try doing this some other way, maybe with optimization remarks.