[LLVMdev] summer of code idea — checking bounds overflow bugs

Adve, Vikram Sadanand
Wed, 31 Mar 2010 19:53:37 -0000

On Mar 31, 2010, at 11:35 AM, John Regehr wrote:
<snip>
>> I'm curious why you think some undefined behavior detectors need to
be built
>> in Clang.  It seems to me that any static analysis could be built using
>> either LLVM or Clang; there are just tradeoffs to each approach.  What
>> advantages does Clang provide?
>
> Some checks must live in Clang because too much information has been lost
> by the time LLVM sees the code.  There are many examples but here is the
> canonical one.  A program has undefined behavior if "between two
sequence
> points, an object is modified more than once, or is modified and the prior
> value is read other than to determine the value to be stored."

I agree.  There are a number of such semantic rules that must be checked in the
front end, another common example being type checking rules for types that are
lowered down to the IR (e.g., all the class related rules in C++).  SAFECode  as
it currently stands doesn't try to address such properties.

>
> To implement this check in LLVM, we would have to answer the question:
> Where, in the LLVM code, are the sequence points?
>
> John

--Vikram