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

            Bug ID: 36274
           Summary: [m32][debug] "Wrong topological sorting" in
                    ScheduleDAG.cpp after r324359
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: ilia.tara...@intel.com
                CC: llvm-bugs@lists.llvm.org

This test fails at ScheduleDAG.cpp with "Wrong topological sorting" after
r324359 using debug build:

================= nice.c ==============
void foo (unsigned long);
unsigned int g = 0;
unsigned long long a [13] [2];
int main ()
{
    unsigned long m = g;
    unsigned long i = 0;
    for (i = 0; i <= 12; i++) 
        a[i][0]++;
    foo(m);
    return 0;
}

=======================================

>>> clang -v
clang version 7.0.0 (trunk 324464)
Target: x86_64-unknown-linux-gnu
Thread model: posix

...


>>> clang -c -m32 -O3 nice.c
clang-7.0: .../llvm/lib/CodeGen/ScheduleDAG.cpp:518: void
llvm::ScheduleDAGTopologicalSort::InitDAGTopologicalSorting(): Assertion
`Node2Index[SU.NodeNum] > Node2Index[PD.getSUnit()->NodeNum] && "Wrong
topological sorting"' failed.


This is small ll reproducer for llc:

================= fine.ll =============
target triple = "i386-unknown-linux-gnu"

@g = external local_unnamed_addr global i32, align 4
@a = external local_unnamed_addr global [13 x [2 x i64]], align 8

; Function Attrs: nounwind
define void @main() local_unnamed_addr #0 {
entry:
  %0 = load i32, i32* @g, align 4
  %1 = load i64, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 0, i32 0), align 8
  %inc = add i64 %1, 1
  store i64 %inc, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 0, i32 0), align 8
  %2 = load i64, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 1, i32 0), align 8
  %inc.1 = add i64 %2, 1
  store i64 %inc.1, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 1, i32 0), align 8
  %3 = load i64, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 2, i32 0), align 8
  %inc.2 = add i64 %3, 1
  store i64 %inc.2, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 2, i32 0), align 8
  %4 = load i64, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 3, i32 0), align 8
  %inc.3 = add i64 %4, 1
  store i64 %inc.3, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 3, i32 0), align 8
  %5 = load i64, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 4, i32 0), align 8
  %inc.4 = add i64 %5, 1
  store i64 %inc.4, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 4, i32 0), align 8
  %6 = load i64, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 5, i32 0), align 8
  %inc.5 = add i64 %6, 1
  store i64 %inc.5, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 5, i32 0), align 8
  %7 = load i64, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 6, i32 0), align 8
  %inc.6 = add i64 %7, 1
  store i64 %inc.6, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 6, i32 0), align 8
  %8 = load i64, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 7, i32 0), align 8
  %inc.7 = add i64 %8, 1
  store i64 %inc.7, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 7, i32 0), align 8
  %9 = load i64, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 8, i32 0), align 8
  %inc.8 = add i64 %9, 1
  store i64 %inc.8, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 8, i32 0), align 8
  %10 = load i64, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 9, i32 0), align 8
  %inc.9 = add i64 %10, 1
  store i64 %inc.9, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 9, i32 0), align 8
  %11 = load i64, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 10, i32 0), align 8
  %inc.10 = add i64 %11, 1
  store i64 %inc.10, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 10, i32 0), align 8
  %12 = load i64, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 11, i32 0), align 8
  %inc.11 = add i64 %12, 1
  store i64 %inc.11, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 11, i32 0), align 8
  %13 = load i64, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 12, i32 0), align 8
  %inc.12 = add i64 %13, 1
  store i64 %inc.12, i64* getelementptr inbounds ([13 x [2 x i64]], [13 x [2 x
i64]]* @a, i32 0, i32 12, i32 0), align 8
  ret void
}

attributes #0 = { nounwind }

=======================================

>>> llc fine.ll
llc: .../llvm/lib/CodeGen/ScheduleDAG.cpp:518: void
llvm::ScheduleDAGTopologicalSort::InitDAGTopologicalSorting(): Assertion
`Node2Index[SU.NodeNum] > Node2Index[PD.getSUnit()->NodeNum] && "Wrong
topological sorting"' failed.


This assertion starts to appear after r324359:
------------------------------------------------------------------------
r324359 | niravd | 2018-02-06 17:14:29 +0100 (Tue, 06 Feb 2018) | 16 lines

[DAG, X86] Improve Dependency analysis when doing multi-node
Instruction Selection

Cleanup cycle/validity checks in ISel (IsLegalToFold,
HandleMergeInputChains) and X86 (isFusableLoadOpStore). Now do a full
search for cycles / dependencies pruning the search when topological
property of NodeId allows.

As part of this propogate the NodeId-based cutoffs to narrow
hasPreprocessorHelper searches.

Reviewers: craig.topper, bogner

Subscribers: llvm-commits, hiraditya

Differential Revision: https://reviews.llvm.org/D41293
------------------------------------------------------------------------

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to