[llvm-dev] Writing static analyzers to detect non-deterministic behavior?

Grang, Mandeep Singh via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 8 19:43:28 PDT 2018


In the past, I had added the ability in LLVM to uncover 2 types of 
non-deterministic behaviors: iteration of unordered containers with 
pointer-like keys and sorting of elements with the same keys.

Now, I wanted to add checkers for these (and other types of 
non-deterministic behaviors) so that they could be applied more widely. 
I also realize that not all of these may be doable at compile-time.

With that in mind, I have pushed a patch which I adds a new category of 
checks for non-determinism: https://reviews.llvm.org/D50488.

The first checker which I have pushed here will simply check if raw 
pointers are being sorted. In subsequent patches, I will fine tune this 
by handling more complex cases of sorting of pointer-like keys.

I have another patch which checks for iteration of unordered containers 
but that may be very noisy in its current form.

I would like comments/suggestions from the community on:

1. Are static analysis checks to detect non-determinism something worth 
doing/doable?

2. How about writing sanitizers to detect non-deterministic behavior? 
Would that be too costly in terms of run time and instrumentation?

--Mandeep



More information about the llvm-dev mailing list