[PATCH] D102764: [IR] Prefer not to delete blocks that have their address taken

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 19 05:48:53 PDT 2021


lebedev.ri created this revision.
lebedev.ri added reviewers: jcranmer, peter.smith, t.p.northover, manojgupta, efriedma, nickdesaulniers, spatel.
lebedev.ri added a project: LLVM.
Herald added subscribers: frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, kristof.beyls, jgravelle-google, arichardson, sbc100, dschuff.
lebedev.ri requested review of this revision.
Herald added subscribers: MaskRay, aheejin.

Honestly, i don't know what should happen when we want to delete
a block that has their address taken.

Currently, when that happens, the `i8* blockaddress(@fun, %bb)`
is replaced with `i8* inttoptr i32 1 to i8*`. Which is obviously
no longer an address of a block, and iff the use semantically required
it to actually be an address of a block, e.g. AArch64's `S` constaint
in `llvm/test/CodeGen/AArch64/inlineasm-S-constraint.ll`,
then the IR suddenly becomes invalid.

I have only noticed this because that test starts to fail
after some SimplifyCFG changes.

So, since, the blocks practically never have their addresses taken,
i would propose to:

1. forbid `DeleteDeadBlocks()` from deleting blocks that have their addresses taken. This will allow to catch the precise codepath that is missing aa precondition.
2. Don't delete blocks that have their addresses taken
3. Allow to delete unreachable that have their addresses taken - taking an address does not count as block reachability.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102764

Files:
  llvm/lib/Transforms/Scalar/JumpThreading.cpp
  llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/test/CodeGen/RISCV/codemodel-lowering.ll
  llvm/test/CodeGen/WebAssembly/indirectbr.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102764.346414.patch
Type: text/x-patch
Size: 6908 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210519/c31bfbbb/attachment.bin>


More information about the llvm-commits mailing list