[PATCH] D144730: [FlowSensitive][WIP] log analysis progress for debugging purposes
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 24 06:03:53 PST 2023
sammccall added a comment.
Example textual log (though better with colors):
=== Beginning data flow analysis ===
int target(int x) {
while (x > 0)
{
--x;
}
return x + 1;
}
FunctionDecl 0x2a9a300 </usr/local/google/home/sammccall/test.cc:1:1, line:6:1> line:1:5 target 'int (int)'
|-ParmVarDecl 0x2a9a238 <col:12, col:16> col:16 used x 'int'
`-CompoundStmt 0x2a9a568 <col:19, line:6:1>
|-WhileStmt 0x2a9a4c0 <line:2:3, line:4:3>
| |-BinaryOperator 0x2a9a450 <line:2:10, col:12> 'bool' '>'
| | |-ImplicitCastExpr 0x2a9a438 <col:10> 'int' <LValueToRValue>
| | | `-DeclRefExpr 0x2a9a3f8 <col:10> 'int' lvalue ParmVar 0x2a9a238 'x' 'int'
| | `-IntegerLiteral 0x2a9a418 <col:12> 'int' 0
| `-CompoundStmt 0x2a9a4a8 <col:15, line:4:3>
| `-UnaryOperator 0x2a9a490 <line:3:5, col:7> 'int' lvalue prefix '--'
| `-DeclRefExpr 0x2a9a470 <col:7> 'int' lvalue ParmVar 0x2a9a238 'x' 'int'
`-ReturnStmt 0x2a9a558 <line:5:3, col:14>
`-BinaryOperator 0x2a9a538 <col:10, col:14> 'int' '+'
|-ImplicitCastExpr 0x2a9a520 <col:10> 'int' <LValueToRValue>
| `-DeclRefExpr 0x2a9a4e0 <col:10> 'int' lvalue ParmVar 0x2a9a238 'x' 'int'
`-IntegerLiteral 0x2a9a500 <col:14> 'int' 1
[B5 (ENTRY)]
Succs (1): B4
[B1]
1: x
2: [B1.1] (ImplicitCastExpr, LValueToRValue, int)
3: 1
4: [B1.2] + [B1.3]
5: return [B1.4];
Preds (1): B4
Succs (1): B0
[B2]
Preds (1): B3
Succs (1): B4
[B3]
1: x
2: --[B3.1]
Preds (1): B4
Succs (1): B2
[B4]
1: x
2: [B4.1] (ImplicitCastExpr, LValueToRValue, int)
3: 0
4: [B4.2] > [B4.3]
T: while [B4.4]
Preds (2): B2 B5
Succs (2): B3 B1
[B0 (EXIT)]
Preds (1): B1
=== Entering block B4 (iteration 1) ===
[B4]
1: x
2: [B4.1] (ImplicitCastExpr, LValueToRValue, int)
3: 0
4: [B4.2] > [B4.3]
T: while [B4.4]
Preds (2): B2 B5
Succs (2): B3 B1
Computed state for B4.0:
DeclToLoc:
ExprToLoc:
LocToVal:
FlowConditionToken:
(=
B0
B1)
(=
B1
B3)
(=
B3
B2)
B0
B2
Processing element B4.1: x
transfer!
Computed state for B4.1:
DeclToLoc:
ExprToLoc:
LocToVal:
FlowConditionToken:
(=
B0
B1)
(=
B1
B3)
(=
B3
B2)
B0
B2
Processing element B4.2: x (ImplicitCastExpr, LValueToRValue, int)
transfer!
Computed state for B4.2:
DeclToLoc:
ExprToLoc:
LocToVal:
FlowConditionToken:
(=
B0
B1)
(=
B1
B3)
(=
B3
B2)
B0
B2
Processing element B4.3: 0
transfer!
Computed state for B4.3:
DeclToLoc:
ExprToLoc:
LocToVal:
FlowConditionToken:
(=
B0
B1)
(=
B1
B3)
(=
B3
B2)
B0
B2
Processing element B4.4: x > 0
transfer!
Computed state for B4.4:
DeclToLoc:
ExprToLoc:
LocToVal:
FlowConditionToken:
(=
B0
B1)
(=
B1
B3)
(=
B3
B2)
B0
B2
=== Entering block B1 (iteration 1) ===
[B1]
1: x
2: [B1.1] (ImplicitCastExpr, LValueToRValue, int)
3: 1
4: [B1.2] + [B1.3]
5: return [B1.4];
Preds (1): B4
Succs (1): B0
Computed state for B1.0:
DeclToLoc:
ExprToLoc:
[0x2a9a450, 0x2ab7e60]
LocToVal:
[0x2ab7e60, 0x2ab7da0: AtomicBool]
FlowConditionToken:
(=
B0
B1)
(=
B1
B3)
(=
B3
B2)
(=
B4
(and
B0
(not
B5)))
(=
B6
B4)
B2
B6
Processing element B1.1: x
transfer!
Computed state for B1.1:
DeclToLoc:
ExprToLoc:
[0x2a9a450, 0x2ab7e60]
LocToVal:
[0x2ab7e60, 0x2ab7da0: AtomicBool]
FlowConditionToken:
(=
B0
B1)
(=
B1
B3)
(=
B3
B2)
(=
B4
(and
B0
(not
B5)))
(=
B6
B4)
B2
B6
Processing element B1.2: x (ImplicitCastExpr, LValueToRValue, int)
transfer!
Computed state for B1.2:
DeclToLoc:
ExprToLoc:
[0x2a9a450, 0x2ab7e60]
LocToVal:
[0x2ab7e60, 0x2ab7da0: AtomicBool]
FlowConditionToken:
(=
B0
B1)
(=
B1
B3)
(=
B3
B2)
(=
B4
(and
B0
(not
B5)))
(=
B6
B4)
B2
B6
Processing element B1.3: 1
transfer!
Computed state for B1.3:
DeclToLoc:
ExprToLoc:
[0x2a9a450, 0x2ab7e60]
LocToVal:
[0x2ab7e60, 0x2ab7da0: AtomicBool]
FlowConditionToken:
(=
B0
B1)
(=
B1
B3)
(=
B3
B2)
(=
B4
(and
B0
(not
B5)))
(=
B6
B4)
B2
B6
Processing element B1.4: x + 1
transfer!
Computed state for B1.4:
DeclToLoc:
ExprToLoc:
[0x2a9a450, 0x2ab7e60]
LocToVal:
[0x2ab7e60, 0x2ab7da0: AtomicBool]
FlowConditionToken:
(=
B0
B1)
(=
B1
B3)
(=
B3
B2)
(=
B4
(and
B0
(not
B5)))
(=
B6
B4)
B2
B6
Processing element B1.5: return x + 1;
transfer!
Computed state for B1.5:
DeclToLoc:
ExprToLoc:
[0x2a9a450, 0x2ab7e60]
LocToVal:
[0x2ab7e60, 0x2ab7da0: AtomicBool]
FlowConditionToken:
(=
B0
B1)
(=
B1
B3)
(=
B3
B2)
(=
B4
(and
B0
(not
B5)))
(=
B6
B4)
B2
B6
=== Entering block B0 (iteration 1) ===
[B0 (EXIT)]
Preds (1): B1
Computed state for B0.0:
DeclToLoc:
ExprToLoc:
[0x2a9a450, 0x2ab7e60]
LocToVal:
[0x2ab7e60, 0x2ab7da0: AtomicBool]
FlowConditionToken:
(=
B0
B1)
(=
B1
B3)
(=
B3
B2)
(=
B4
(and
B0
(not
B5)))
(=
B6
B4)
(=
B7
B8)
(=
B8
B6)
B2
B7
=== Entering block B3 (iteration 1) ===
[B3]
1: x
2: --[B3.1]
Preds (1): B4
Succs (1): B2
Computed state for B3.0:
DeclToLoc:
ExprToLoc:
[0x2a9a450, 0x2ab7e60]
LocToVal:
[0x2ab7e60, 0x2aba810: AtomicBool]
FlowConditionToken:
(=
B0
B1)
(=
B1
B3)
(=
B3
B2)
(=
B4
B5)
(=
B5
(and
B0
B6))
B2
B4
Processing element B3.1: x
transfer!
Computed state for B3.1:
DeclToLoc:
ExprToLoc:
[0x2a9a450, 0x2ab7e60]
LocToVal:
[0x2ab7e60, 0x2aba810: AtomicBool]
FlowConditionToken:
(=
B0
B1)
(=
B1
B3)
(=
B3
B2)
(=
B4
B5)
(=
B5
(and
B0
B6))
B2
B4
Processing element B3.2: --x
transfer!
Computed state for B3.2:
DeclToLoc:
ExprToLoc:
[0x2a9a450, 0x2ab7e60]
LocToVal:
[0x2ab7e60, 0x2aba810: AtomicBool]
FlowConditionToken:
(=
B0
B1)
(=
B1
B3)
(=
B3
B2)
(=
B4
B5)
(=
B5
(and
B0
B6))
B2
B4
=== Entering block B2 (iteration 1) ===
[B2]
Preds (1): B3
Succs (1): B4
Computed state for B2.0:
DeclToLoc:
ExprToLoc:
[0x2a9a450, 0x2ab7e60]
LocToVal:
[0x2ab7e60, 0x2aba810: AtomicBool]
FlowConditionToken:
(=
B0
B1)
(=
B1
B3)
(=
B3
B2)
(=
B4
B5)
(=
B5
B7)
(=
B6
B4)
(=
B7
(and
B0
B8))
B2
B6
=== Entering block B4 (iteration 2) ===
[B4]
1: x
2: [B4.1] (ImplicitCastExpr, LValueToRValue, int)
3: 0
4: [B4.2] > [B4.3]
T: while [B4.4]
Preds (2): B2 B5
Succs (2): B3 B1
Computed state for B4.0:
DeclToLoc:
ExprToLoc:
LocToVal:
FlowConditionToken:
(=
B0
B1)
(=
B1
B7)
(=
B10
(and
B2
B12))
(=
B11
(or
B0
B5))
(=
B2
B3)
(=
B3
B1)
(=
B4
B11)
(=
B5
B6)
(=
B6
B8)
(=
B8
B9)
(=
B9
B10)
B4
B7
Processing element B4.1: x
transfer!
Computed state for B4.1:
DeclToLoc:
ExprToLoc:
LocToVal:
FlowConditionToken:
(=
B0
B1)
(=
B1
B7)
(=
B10
(and
B2
B12))
(=
B11
(or
B0
B5))
(=
B2
B3)
(=
B3
B1)
(=
B4
B11)
(=
B5
B6)
(=
B6
B8)
(=
B8
B9)
(=
B9
B10)
B4
B7
Processing element B4.2: x (ImplicitCastExpr, LValueToRValue, int)
transfer!
Computed state for B4.2:
DeclToLoc:
ExprToLoc:
LocToVal:
FlowConditionToken:
(=
B0
B1)
(=
B1
B7)
(=
B10
(and
B2
B12))
(=
B11
(or
B0
B5))
(=
B2
B3)
(=
B3
B1)
(=
B4
B11)
(=
B5
B6)
(=
B6
B8)
(=
B8
B9)
(=
B9
B10)
B4
B7
Processing element B4.3: 0
transfer!
Computed state for B4.3:
DeclToLoc:
ExprToLoc:
LocToVal:
FlowConditionToken:
(=
B0
B1)
(=
B1
B7)
(=
B10
(and
B2
B12))
(=
B11
(or
B0
B5))
(=
B2
B3)
(=
B3
B1)
(=
B4
B11)
(=
B5
B6)
(=
B6
B8)
(=
B8
B9)
(=
B9
B10)
B4
B7
Processing element B4.4: x > 0
transfer!
Computed state for B4.4:
DeclToLoc:
ExprToLoc:
LocToVal:
FlowConditionToken:
(=
B0
B1)
(=
B1
B7)
(=
B10
(and
B2
B12))
(=
B11
(or
B0
B5))
(=
B2
B3)
(=
B3
B1)
(=
B4
B11)
(=
B5
B6)
(=
B6
B8)
(=
B8
B9)
(=
B9
B10)
B4
B7
B4 has converged!
=== Finished analysis: 5 blocks in 6 total steps ===
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144730/new/
https://reviews.llvm.org/D144730
More information about the cfe-commits
mailing list