[PATCH] D110751: [DomTree] Assert that blocks in queries aren't from another function

Daniil Suchkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 30 12:23:10 PDT 2021


DaniilSuchkov updated this revision to Diff 376325.
DaniilSuchkov added a comment.

That was wrong diff.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110751/new/

https://reviews.llvm.org/D110751

Files:
  llvm/include/llvm/Support/GenericDomTree.h
  llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-invariant-select-bug.ll


Index: llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-invariant-select-bug.ll
===================================================================
--- llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-invariant-select-bug.ll
+++ llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-invariant-select-bug.ll
@@ -1,34 +1,15 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -passes='simple-loop-unswitch<nontrivial>' -S < %s | FileCheck %s
+; REQUIRES: asserts
+; XFAIL: *
+; RUN: opt -passes='simple-loop-unswitch<nontrivial>' -S < %s -disable-output
 
-; FIXME: We should not replace `true` with `false` here!
+; If we try to replace uses of `true` outside of `@foo`, we'll see it here.
 define i1 @bar() {
-; CHECK-LABEL: @bar(
-; CHECK-NEXT:    ret i1 false
-;
   ret i1 true
 }
 
-; FIXME: We shouldn't unswitch this loop!
+; We shouldn't unswitch this loop.
 define void @foo() {
-; CHECK-LABEL: @foo(
-; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 true, label [[ENTRY_SPLIT_US:%.*]], label [[ENTRY_SPLIT:%.*]]
-; CHECK:       entry.split.us:
-; CHECK-NEXT:    br label [[HEADER_US:%.*]]
-; CHECK:       header.us:
-; CHECK-NEXT:    [[VAL_US:%.*]] = select i1 true, i1 true, i1 false
-; CHECK-NEXT:    br label [[EXIT_SPLIT_US:%.*]]
-; CHECK:       exit.split.us:
-; CHECK-NEXT:    br label [[EXIT:%.*]]
-; CHECK:       entry.split:
-; CHECK-NEXT:    br label [[HEADER:%.*]]
-; CHECK:       header:
-; CHECK-NEXT:    [[VAL:%.*]] = select i1 false, i1 false, i1 false
-; CHECK-NEXT:    br label [[HEADER]]
-; CHECK:       exit:
-; CHECK-NEXT:    ret void
-;
 entry:
   br label %header
 
Index: llvm/include/llvm/Support/GenericDomTree.h
===================================================================
--- llvm/include/llvm/Support/GenericDomTree.h
+++ llvm/include/llvm/Support/GenericDomTree.h
@@ -349,6 +349,9 @@
   /// may (but is not required to) be null for a forward (backwards)
   /// statically unreachable block.
   DomTreeNodeBase<NodeT> *getNode(const NodeT *BB) const {
+    assert((!BB || !BB->getParent() || BB->getParent() == Parent) &&
+           "A node from another function!");
+
     auto I = DomTreeNodes.find(BB);
     if (I != DomTreeNodes.end())
       return I->second.get();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110751.376325.patch
Type: text/x-patch
Size: 2278 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210930/52fe4b6d/attachment.bin>


More information about the llvm-commits mailing list