llvm-project
3b193695 - [analyzer] Regularize conjured sym for return area of entrypoint (#244444)

Commit
2 days ago
[analyzer] Regularize conjured sym for return area of entrypoint (#244444) In C++ the function analyzed as the entrypoint may "return" by constructing an object at a memory area in the context of its caller (which is not part of the symbolic execution). To model this situation the analyzer conjures a symbolic region to represent the memory area where the object will be constructed. When a symbol is conjured this way, `SF` (passed to `conjureSymbolVal`) is the entry stack frame, which may be different from `getCurrStackFrame()` (the currently analyzed stack frame) in code like ``` Obj inner() { Obj o; return o; } Obj entrypoint() { return inner(); } ``` (Analysis of this code invokes `computeObjectUnderConstruction` at a point when `getCurrStackFrame()` is the frame of `inner()`.) Among the situations covered by LIT tests, this was the only one where a conjured symbol was initialized with a stack frame that is different from `getCurrStackFrame()`. This change eliminates this irregularity because it did not serve any useful purpose: on a single path there should be only one "area where the return value of the entrypoint is constructed" symbol, and that symbol is distinguished by its unique tag, so other distinguishing features like the stack frame are practically irrelevant. This change is almost completely NFC: the only theoretically possible functional effect is that it could prevent the merge of two execution paths that only differ in the stack frame where their "return from entrypoint" function was conjured. This is an extremely unlikely situation (all other state components must be identical, and the different stack frames must correspond to different calls of the same recursive function, because otherwise the `CFGElement` would also distinguish the conjured symbols) and even in this situation the only effect is that the separate but equivalent paths consume the analysis budget twice (which cannot introduce false positives and often wouldn't have any visible effect). This change prepares the ground for the simplification of the interface for conjuring symbols.
Author
Parents
Loading