[PATCH] D61300: [SCCP] Fix crash when trying to constant-fold terminators multiple times.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 7 10:04:01 PDT 2019


fhahn marked an inline comment as done.
fhahn added a comment.

In D61300#1493707 <https://reviews.llvm.org/D61300#1493707>, @jdoerfert wrote:

> Do we need to "repair" the folded branch or could we also determine earlier that the current block is dead (it will have an unconditional branch to a dead block, right?) and avoid folding?
>  It might make sense to fold due to the DT update though.


We could skip calling `forceIndeterminateEdge` and `ConstantFoldTerminator`, if all successors are not executable. But I think it is better to keep the current structure, because the assertion that we managed to fold the terminator has been helpful in catching inconsistencies in the past and it is probably also quicker e.g. if you have switch statements with a large number of successors.



================
Comment at: llvm/lib/Transforms/Scalar/SCCP.cpp:2087
+        auto *BB = I->getParent();
         bool Folded = ConstantFoldTerminator(I->getParent(),
                                              /*DeleteDeadConditions=*/false,
----------------
jdoerfert wrote:
> now `BB`
Do you mean omitting the `*` with `auto`? There's no reason to use `auto` here, I'll change it to `BasicBlock`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61300/new/

https://reviews.llvm.org/D61300





More information about the llvm-commits mailing list