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

John Regehr regehr at cs.utah.edu
Wed Mar 31 09:48:30 PDT 2010


> 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."
>
> To implement this check in LLVM, we would have to answer the question:
> Where, in the LLVM code, are the sequence points?

By the way I can hear readers of this list saying to themselves "this does 
not seem like a useful check to implement."  Perhaps this is correct, but 
let's consider the tradeoffs:

- This is a relatively simple, localized check that should not be too hard 
to implement.

- Almost all of the added checks would be destroyed by LLVM after simple 
queries to the alias analyzer, so applications running with this check 
turned on will not slow down much.

- Common optimizing compilers change the meaning of a computation that 
makes this mistake.

My guess is that this check would find problems in real apps...

John



More information about the llvm-dev mailing list