[llvm-bugs] [Bug 31758] New: [NewGVN] Crash while looking up domtree node

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 25 11:47:07 PST 2017


https://llvm.org/bugs/show_bug.cgi?id=31758

            Bug ID: 31758
           Summary: [NewGVN] Crash while looking up domtree node
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: davide at freebsd.org
                CC: dberlin at dberlin.org, llvm-bugs at lists.llvm.org
            Blocks: 30995
    Classification: Unclassified

We mark a block unreachable so DT->getNode() returns nullptr. Maybe there's a
different/more correct way to fix this. Tried to bootstrap/test suite.

Testcase reduced from one of our internal codebases (game7).

%struct.dipsy = type {}
%struct.fluttershy = type { %struct.dipsy* }
%struct.patatino = type {}

define void @tinkywinky() {
bb:
  br label %bb90

bb90:                                             ; preds = %bb90, %bb
  %tmp = getelementptr inbounds %struct.fluttershy, %struct.fluttershy* undef,
i64 0, i32 0
  %tmp91 = bitcast %struct.dipsy** %tmp to %struct.patatino**
  %tmp92 = load %struct.patatino*, %struct.patatino** %tmp91, align 8
  %tmp99 = getelementptr inbounds %struct.patatino, %struct.patatino* %tmp92
  %tmp134 = getelementptr inbounds %struct.fluttershy, %struct.fluttershy*
undef, i64 0, i32 0
  %tmp135 = bitcast %struct.dipsy** %tmp134 to %struct.patatino**
  %tmp136 = load %struct.patatino*, %struct.patatino** %tmp135, align 8
  br label %bb90

bb138:                                            ; preds = %bb138
  %tmp139 = getelementptr inbounds %struct.patatino, %struct.patatino* %tmp136
  br label %bb138
}

Proposed patch:

fluttershy at SONY-PC C:\Users\fluttershy\work\llvm
> git diff
diff --git a/lib/Transforms/Scalar/NewGVN.cpp
b/lib/Transforms/Scalar/NewGVN.cpp
index d4e41e1..cc87c79 100644
--- a/lib/Transforms/Scalar/NewGVN.cpp
+++ b/lib/Transforms/Scalar/NewGVN.cpp
@@ -1939,8 +1939,14 @@ void NewGVN::convertDenseToDFSOrdered(
           VD.LocalNum = InstrDFS.lookup(I);
         }
         DomTreeNode *DomNode = DT->getNode(IBlock);
-        VD.DFSIn = DomNode->getDFSNumIn();
-        VD.DFSOut = DomNode->getDFSNumOut();
+        if (DomNode) {
+          VD.DFSIn = DomNode->getDFSNumIn();
+          VD.DFSOut = DomNode->getDFSNumOut();
+        }
+        else {
+          VD.DFSIn = 0;
+          VD.DFSOut = 0;
+        }
         VD.U = &U;
         DFSOrderedSet.emplace_back(VD);
       }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170125/bef0f143/attachment.html>


More information about the llvm-bugs mailing list