[PATCH] D121744: [SCCP] Update ValueLatticeElement blockaddresses when removing unreachable BasicBlocks

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 15 15:00:14 PDT 2022


nickdesaulniers created this revision.
nickdesaulniers added reviewers: nikic, bcl5980, efriedma.
Herald added subscribers: hiraditya, arichardson.
Herald added a project: All.
nickdesaulniers requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Fixes a crash observed in ipsccp.

When SCCP's SCCPSolver determines that a BasicBlock is unreachable, it
removes it. Unfortunately, there may already be ValueLatticeElements
that refer to the BasicBlock's BlockAddress already referenced within
the solver.

To fix this:

1. Replace the `i8* blockaddress(@fn, %bb)` with `i8* inttoptr(i32 1 to i8*)`.
2. Find the ValueLatticeElements that may refer to the previous `BlockAddress`' `User`s.
3. Update those to use the new `IntToPtrInst` `Value`.

Fixes: https://github.com/llvm/llvm-project/issues/54238
Fixes: https://github.com/llvm/llvm-project/issues/54251


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121744

Files:
  llvm/include/llvm/Transforms/Utils/SCCPSolver.h
  llvm/lib/Transforms/Scalar/SCCP.cpp
  llvm/lib/Transforms/Utils/SCCPSolver.cpp
  llvm/test/Transforms/SCCP/dangling-block-address.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121744.415599.patch
Type: text/x-patch
Size: 4347 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220315/1a348592/attachment.bin>


More information about the llvm-commits mailing list