[PATCH] D35918: [GVNHoist] Factor out reachability to search for anticipable instructions quickly
Jakub Kuderski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 3 15:00:56 PDT 2017
kuhar added a comment.
In https://reviews.llvm.org/D35918#831102, @hiraditya wrote:
>
> Try `./bin/opt -S -adce < llvm/test/Transforms/GVNHoist/infinite-loop-direct.ll`
>
> with the following patch. I added the code here for easy reproducibility.
>
> diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp
> index 5b467dc..eb711b9 100644
> --- a/lib/Transforms/Scalar/ADCE.cpp
> +++ b/lib/Transforms/Scalar/ADCE.cpp
> @@ -164,6 +164,10 @@ public:
> }
>
> bool AggressiveDeadCodeElimination::performDeadCodeElimination() {
> + auto PrevBB = PDT.getNode(nullptr);
> + for (auto it = df_begin(PrevBB), E = df_end(PrevBB); it != E; ++it) {
> + dbgs() << "\nTest\n";
> + }
>
>
> Here is the reduced test case:
>
> $ cat a.ll
> ; ModuleID = 'bugpoint-reduced-simplified.bc'
> source_filename = "bugpoint-output-f4ca947.bc"
> target triple = "x86_64-unknown-linux-gnu"
>
> define void @bazv1() local_unnamed_addr {
> entry:
> br label %while.cond
>
> while.cond: ; preds = %while.cond, %entry
> br label %while.cond
> }
>
Oh, yes, that happens because the entire function is reverse-unreachable, which causes the tree to be completely empty. https://reviews.llvm.org/D35851 puts reverse-unreachable CFG nodes in the tree and solves this problem.
In the meanwhile, you can check if `PDT.getNode(nullptr)` returns a nullptr and not iterate over it that situation.
https://reviews.llvm.org/D35918
More information about the llvm-commits
mailing list