[PATCH] D131646: [clang][dataflow] Restructure loops to call widen on back edges
Gábor Horváth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 11 11:18:08 PDT 2022
xazax.hun added inline comments.
================
Comment at: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp:168-169
+// back edge block. (That is, all paths from the entry block to the back edge
+// block must go through `Block`.) It also means that there are only two
+// predecessors; the other is along the path from the entry block to `Block`.
+static const CFGBlock *findBackEdge(const CFGBlock *Block) {
----------------
Is this also true when we have multiple `continue` statements in the loop?
================
Comment at: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp:228-234
+ // If we are at the start of a loop, we will have two precessors, but we don't
+ // want to join these two predecessors. Instead, we want to take the back edge
+ // block (i.e. the result of the previous iteration) and use that directly as
+ // the input block.
+ //
+ // For the first iteration of loop, the "zeroth" iteration state is set up by
+ // `prepareBackEdges`.
----------------
Could you elaborate on this? Let's consider this loop:
```
Pred
|
v
LoopHeader <---BackEdge
```
Do we ignore the state coming from `Pred` on purpose? Is that sound?
I would expect the analysis to always compute `join(PredState, BackEdgeState)`, and I would expect the widening to happen between the previous iteration of `BackEdgeState` and the current iteration of `BackEdgeState`. So, I wonder if we already invoke the widening operator along back edges, wouldn't the regular logic work just fine? Do I miss something?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131646/new/
https://reviews.llvm.org/D131646
More information about the cfe-commits
mailing list