Currently we only consider basic blocks with a unique predecessor when
estimating the size of dead code. However, we could expand to this to
consider blocks with a back-edge, or blocks preceded by dead blocks.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/IPO/FunctionSpecialization.cpp | ||
---|---|---|
109–117 | My instinct reaction to the function is "doesn't DeadBlocks contain DeadBB"? |
So generally, when we encounter root dead blocks, then their predecessor will not be in DeadBlocks. Successors of known dead blocks do have at least one predecessor in DeadBlocks (the one we followed while traversing the graph).
llvm/lib/Transforms/IPO/FunctionSpecialization.cpp | ||
---|---|---|
109–117 | Not yet. If isBlockExecutable and canEliminateSuccessor, then we push it to the work list. Blocks are marked dead after being popped from the work list. | |
158 | Here, BB, which is the predecessor of SuccBB, is indeed already in DeadBlocks. | |
247 | Here, BB corresponds to the not taken branch. If I.getParent is the predecessor of BB (despite not being in DeadBlocks), we can eliminate BB. | |
265 | Here, Succ corresponds to the not taken branch. If I.getParent is the predecessor of Succ (despite not being in DeadBlocks), we can eliminate Succ. |
LGTM with nit.
Sorry that I imaged I commented on this : (
llvm/lib/Transforms/IPO/FunctionSpecialization.cpp | ||
---|---|---|
109–117 | Got it. nit: Then I feel slightly better to make it a static private member function of InstCostVisitor. Then the reader may be less confused. |
My instinct reaction to the function is "doesn't DeadBlocks contain DeadBB"?