[PATCH] D64162: Summary: [Attributor] Liveness analysis abstract attribute used to indicate which BasicBlocks are dead and can therefore be ignored.
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 5 11:39:07 PDT 2019
jdoerfert added a comment.
I guess we need to implement a manifest to make testing easier.
I'd propose the following in the manifest method:
Split the block that is dead after the phi-nodes (see `splitBasicBlock`) and replace the unconditional jump with a `llvm_unreachable`.
On second thought, maybe manifest should go through the list of `noreturn` calls and place `llvm_unreachable` after them. Later, we will
have more "sources" in addition to `noreturn` and then we introduce the unreachable after all of them.
================
Comment at: llvm/include/llvm/Transforms/IPO/Attributor.h:723
+ /// Returns true if nounwind is known.
+ virtual bool isKnownDead() const = 0;
};
----------------
I think these methods need to take a basic block and/or instruction.
================
Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:1016
+
+ for (Instruction &I : instructions(&F)) {
+ ImmutableCallSite ICS(&I);
----------------
You need to explore the function in a different way:
Keep a list of "to be expored" paths defined by instructions.
Start with the first instruction in the entry block as a first "to be explored path".
Continue to the next instruction if it is not a `noreturn` call.
If it is the last in the block, add all successors instructions to the "to be explored" path list.
Make sure you never follow a path/instruction twice.
The functionality above should live in a separate function as it will be needed in the update method as well.
Basically, update is the same thing but the start points are all `noreturn` calls that are not `noreturn` anymore.
================
Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:1026
+ /// If the block contains a noreturn call, it is assumed dead.
+ AssumedDeadBlocks.insert(I.getParent());
+ }
----------------
The code __after__ the `noreturn` call is assumed dead but not the block.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64162/new/
https://reviews.llvm.org/D64162
More information about the llvm-commits
mailing list