@@ -2,7 +2,83 @@ private import cpp
22
33cached
44private module Cached {
5-
5+ cached
6+ newtype TContent =
7+ TNonUnionContent ( CanonicalField f , int indirectionIndex ) {
8+ // the indirection index for field content starts at 1 (because `TNonUnionContent` is thought of as
9+ // the address of the field, `FieldAddress` in the IR).
10+ indirectionIndex = [ 1 .. max ( SsaImpl:: getMaxIndirectionsForType ( f .getAnUnspecifiedType ( ) ) ) ] and
11+ // Reads and writes of union fields are tracked using `UnionContent`.
12+ not f .getDeclaringType ( ) instanceof Union
13+ } or
14+ TUnionContent ( CanonicalUnion u , int bytes , int indirectionIndex ) {
15+ exists ( CanonicalField f |
16+ f = u .getACanonicalField ( ) and
17+ bytes = getFieldSize ( f ) and
18+ // We key `UnionContent` by the union instead of its fields since a write to one
19+ // field can be read by any read of the union's fields. Again, the indirection index
20+ // is 1-based (because 0 is considered the address).
21+ indirectionIndex =
22+ [ 1 .. max ( SsaImpl:: getMaxIndirectionsForType ( getAFieldWithSize ( u , bytes )
23+ .getAnUnspecifiedType ( ) )
24+ ) ]
25+ )
26+ } or
27+ TElementContent ( int indirectionIndex ) {
28+ indirectionIndex = [ 1 .. getMaxElementContentIndirectionIndex ( ) ]
29+ }
30+
31+ /**
32+ * The IR dataflow graph consists of the following nodes:
33+ * - `Node0`, which injects most instructions and operands directly into the
34+ * dataflow graph.
35+ * - `VariableNode`, which is used to model flow through global variables.
36+ * - `PostUpdateNodeImpl`, which is used to model the state of an object after
37+ * an update after a number of loads.
38+ * - `SsaSynthNode`, which represents synthesized nodes as computed by the shared SSA
39+ * library.
40+ * - `RawIndirectOperand`, which represents the value of `operand` after
41+ * loading the address a number of times.
42+ * - `RawIndirectInstruction`, which represents the value of `instr` after
43+ * loading the address a number of times.
44+ */
45+ cached
46+ newtype TIRDataFlowNode =
47+ TNode0 ( Node0Impl node ) { DataFlowImplCommon:: forceCachingInSameStage ( ) } or
48+ TGlobalLikeVariableNode ( GlobalLikeVariable var , int indirectionIndex ) {
49+ indirectionIndex =
50+ [ getMinIndirectionsForType ( var .getUnspecifiedType ( ) ) .. SsaImpl:: getMaxIndirectionsForType ( var .getUnspecifiedType ( ) ) ]
51+ } or
52+ TPostUpdateNodeImpl ( Operand operand , int indirectionIndex ) {
53+ isPostUpdateNodeImpl ( operand , indirectionIndex )
54+ } or
55+ TSsaSynthNode ( SsaImpl:: SynthNode n ) or
56+ TSsaIteratorNode ( IteratorFlow:: IteratorFlowNode n ) or
57+ TRawIndirectOperand0 ( Node0Impl node , int indirectionIndex ) {
58+ SsaImpl:: hasRawIndirectOperand ( node .asOperand ( ) , indirectionIndex )
59+ } or
60+ TRawIndirectInstruction0 ( Node0Impl node , int indirectionIndex ) {
61+ not exists ( node .asOperand ( ) ) and
62+ SsaImpl:: hasRawIndirectInstruction ( node .asInstruction ( ) , indirectionIndex )
63+ } or
64+ TFinalParameterNode ( Parameter p , int indirectionIndex ) {
65+ exists ( SsaImpl:: FinalParameterUse use |
66+ use .getParameter ( ) = p and
67+ use .getIndirectionIndex ( ) = indirectionIndex
68+ )
69+ } or
70+ TFinalGlobalValue ( SsaImpl:: GlobalUse globalUse ) or
71+ TInitialGlobalValue ( SsaImpl:: GlobalDef globalUse ) or
72+ TBodyLessParameterNodeImpl ( Parameter p , int indirectionIndex ) {
73+ // Rule out parameters of catch blocks.
74+ not exists ( p .getCatchBlock ( ) ) and
75+ // We subtract one because `getMaxIndirectionsForType` returns the maximum
76+ // indirection for a glvalue of a given type, and this doesn't apply to
77+ // parameters.
78+ indirectionIndex = [ 0 .. SsaImpl:: getMaxIndirectionsForType ( p .getUnspecifiedType ( ) ) - 1 ] and
79+ not any ( InitializeParameterInstruction init ) .getParameter ( ) = p
80+ } or
81+ TFlowSummaryNode ( FlowSummaryImpl:: Private:: SummaryNode sn )
682}
783
884import Cached
0 commit comments