[all-commits] [llvm/llvm-project] 085659: Ensure `collectTransitivePredecessors` returns Pre...

Manish Kausik H via All-commits all-commits at lists.llvm.org
Thu Oct 31 11:08:38 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0856592f6f8d2bdaf2d66017d073b8d55fc27552
      https://github.com/llvm/llvm-project/commit/0856592f6f8d2bdaf2d66017d073b8d55fc27552
  Author: Manish Kausik H <46352931+Nirhar at users.noreply.github.com>
  Date:   2024-10-31 (Thu, 31 Oct 2024)

  Changed paths:
    M llvm/lib/Analysis/MustExecute.cpp
    A llvm/test/Analysis/MustExecute/irreducible-cfg.ll

  Log Message:
  -----------
  Ensure `collectTransitivePredecessors` returns Pred only from the Loop. (#113831)

It's possible that we encounter Irreducible control flow, due to which,
we may find that a few predecessors of BB are not a part of the CurLoop.
Currently we crash in the function for such cases. This patch ensures
that we only return Predecessors that are a part of CurLoop and
gracefully ignore other Predecessors.

For example, consider Irreducible IR of this form:
```
define i64 @baz() {
bb:
  br label %bb1

bb1:                                              ; preds = %bb3, %bb
  br label %bb3

bb2:                                              ; No predecessors!
  br label %bb3

bb3:                                              ; preds = %bb2, %bb1
  %load = load ptr addrspace(1), ptr addrspace(1) null, align 8
  br label %bb1
}
```

This crashes when `collectTransitivePredecessors` is called on the
`%bb1<Header>, %bb3<latch>` loop, because the loop body has a
predecessor `%bb2` which is not a part of the loop.

See https://godbolt.org/z/E9fM1q3cT for the crash



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list