[PATCH] D153638: [CodeGenPrepare][NFC] Update the dominator tree instead of rebuilding it

Momchil Velikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 9 09:37:30 PDT 2023


chill updated this revision to Diff 548647.
chill added a comment.
This revision is now accepted and ready to land.

Fixed the crash during compilation. Requesting the DT, while vising all the function blocks, can have the side effect of
deleting blocks, which can cause the traversal to access free/reused memory.

I think I fixed this by checking/making sure all the loops over the basic blocks fall into these cases:

- basic traversal (e.g `for (auto &BB : F) ... `) while //not// requesting the DT in the body of the loop.
- traversal using an auxiliary vector of `WeakTrackingVH`s.
- the main loops of the pass:

  DTU->flush();
  for (BasicBlock &BB : llvm::make_early_inc_range(F)) {

which can only delete the current block (in `dupRetToEnableTailCallOpts`).
The extra flush of the DTU (added in this update) ensures the current block is valid at the start of the first iteration
and the early increment ensures the block is valid at the start of each subsequent iteration.


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

https://reviews.llvm.org/D153638

Files:
  llvm/include/llvm/Transforms/Utils/BypassSlowDivision.h
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/Transforms/Utils/BypassSlowDivision.cpp
  llvm/test/Transforms/CodeGenPrepare/AMDGPU/bypass-slow-div-debug-info-inseltpoison.ll
  llvm/test/Transforms/CodeGenPrepare/AMDGPU/bypass-slow-div-debug-info.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153638.548647.patch
Type: text/x-patch
Size: 38857 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230809/3bdca392/attachment.bin>


More information about the llvm-commits mailing list