[cfe-dev] [GSoC] Re: CSA constraint solver improvements

Manas via cfe-dev cfe-dev at lists.llvm.org
Mon Apr 12 15:20:00 PDT 2021


On Mon, Apr 12, 2021 at 12:08:23PM +0300, Valeriy Savchenko wrote:
> On 12 Apr 2021, at 03:30, Manas <manas18244 at iiitd.ac.in> wrote:
> > I went through the code in RangeConstraintManager.cpp and comprehended
> > about the constraint manager overall. canReasonAbout() (line: 1948)
> > shows which all operations are left being implemented (namely, Mul, Div, 
> > Shl, Shr, and also the Xor operator). I have added these into the
> > proposal.
> There is also an elephant in the room, - Add and Sub.
> > 
I have added these too.

> > Regarding the TODO #1 (L:931) and TODO #2 (L:936) in RangeConstraintManager.cpp, 
> > should I put these into the proposal too? (this to be done for other binary 
> > operations as well apart from {rem, and, or} operations)
> It didn’t seem to cause any performance problems so far, and I’d say this is not a priority right now.
> 
Understood. I removed them from the timeline.

> > The description of project also mentions about a unit-test framework.
> > Can I get more details regarding this?
> As you looked through those patches, you probably noticed that we usually add more checks into constant-folding.c test.
> It is pretty good, but it would be much better to have a dedicated section of unit-tests especially because the solver is pretty isolated and doesn’t really depend on AST (only on APSInt’s actually, but this is easy to overcome, you can see how it is done in RangeSetTest.cpp).
> 
> I guess my idea of perfect unit tests for the solver would be to have a special class for test symbols that we can construct like this TestSymbol x = {{0, 10}, {20, 40}} with overloaded operators that call solver, so we can do stuff like this: TestSymbol z = x + y; /* check for expected ranges in z */
> This way the actual tests are very straightforward, easy to add new ones, easy to read and maintain.  And all the nitty gritty should be hidden inside of the test class and the test symbol class. The main challenge here is to design this testing framework, so it is as invisible as possible.
> > 
I went through RangeSetTest.cpp. Now I have a clearer picture of the
framework. Basically, as you said, we need to have class abstraction
and methods wrapping around various types of checks for operators.

The segregation of test cases should be based upon the binary operation
(as in constant-folding.c).

-- 
Manas
CSAM Undergraduate | 2022
IIIT-Delhi, India


More information about the cfe-dev mailing list