llvm-project/llvm/lib/Transforms
Max Kazantsev 1f73310e1e [BasicBlockUtils] Generalize DeleteDeadBlock to deal with multiple dead blocks
Utility function `DeleteDeadBlock` expects that all predecessors of a block being
deleted are already deleted, with the exception of single-block loop. It makes it
hard to use for deletion of a set of blocks that may contain cyclic dependencies.
The is no correct order of invocations of this function that does not produce
dangling pointers on already deleted blocks.

This patch introduces a generalized version of this function `DeleteDeadBlocks`
that allows us to remove multiple blocks at once, even if there are cycles among
them. The only requirement is that no block being deleted should have a predecessor
that is not being deleted. 

The logic of `DeleteDeadBlocks` is following:
  for each block
    create relevant DT updates;
    remove all instructions (replace with undef if needed);
    replace terminator with unreacheable;
  apply DT updates;
  for each block
    delete block;

Therefore, `DeleteDeadBlock` becomes a particular case of
the general algorithm called for a single block.

Differential Revision: https://reviews.llvm.org/D56120
Reviewed By: skatkov

llvm-svn: 351045
2019-01-14 10:26:26 +00:00
..
AggressiveInstCombine Format AggresiveInstCombine.cpp. NFC 2019-01-02 19:51:46 +00:00
Coroutines Fix compiler warning about unused variable [NFC] 2018-12-12 06:33:45 +00:00
Hello cmake: Remove add_llvm_loadable_module() 2018-12-20 22:04:08 +00:00
IPO Give helper classes/functions local linkage. NFC. 2019-01-12 18:36:22 +00:00
InstCombine [InstCombine] canonicalize another raw IR rotate pattern to funnel shift 2019-01-08 22:39:55 +00:00
Instrumentation Give helper classes/functions local linkage. NFC. 2019-01-12 18:36:22 +00:00
ObjCARC [CallSite removal] Migrate all Alias Analysis APIs to use the newly 2019-01-07 05:42:51 +00:00
Scalar Give helper classes/functions local linkage. NFC. 2019-01-12 18:36:22 +00:00
Utils [BasicBlockUtils] Generalize DeleteDeadBlock to deal with multiple dead blocks 2019-01-14 10:26:26 +00:00
Vectorize [LoopVectorizer] give more advice in remark about failure to vectorize call 2019-01-12 15:27:15 +00:00
CMakeLists.txt Another try to commit 323321 (aggressive instruction combine). 2018-01-25 12:06:32 +00:00
LLVMBuild.txt Another try to commit 323321 (aggressive instruction combine). 2018-01-25 12:06:32 +00:00