This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Prepare structures for integral cast feature introducing
Needs ReviewPublic

Authored by ASDenysPetrov on Nov 18 2022, 12:21 PM.

Details

Summary

Change structures of storing bindings between Symbols and Equivalent Classes.
Add a Bitwidth characteristic as a common feature of integral Symbol to make (char)(int x) and (uchar)(int x) treated under the same Equivalent Class.

The link Symbol - Class was direct and now it depends on the effective (minimal) Bitwidth of the Symbol.
The link Class - Symbol stays as previously.

effective bitwidth - a bitwidth which is enough to hold all feasible values of the symbol. E.g. for (unsigned short)(char)(int)x, the symbol has a type of unsigned short but in range [0, 255] because it is restricted by the size of char during casting.

Some test cases are affected by regression for the sake of the next patch which will fix it.

This patch does not introduce integral casts but prepares the field for the core patch.

Diff Detail

Event Timeline

ASDenysPetrov created this revision.Nov 18 2022, 12:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 18 2022, 12:21 PM
ASDenysPetrov requested review of this revision.Nov 18 2022, 12:21 PM

I spent some time on this patch. But I'm left thinking about why we need the extra indirection?
Couldn't we just use a std::pair<sym,width> pair as a key instead?
You mention effective bitwidths in your summary, but the code does not mention this concept.
Maybe you could elaborate on what effective bitwidth means in this context and how this changes the eqclass lookups.
In addition to this, I'd be curious about an informal proof of the correctness.

ASDenysPetrov edited the summary of this revision. (Show Details)Nov 25 2022, 2:03 AM