This is an archive of the discontinued LLVM Phabricator instance.

[Dominators] Visit affected node candidates found at different root levels
ClosedPublic

Authored by kuhar on Jan 17 2018, 11:48 PM.

Details

Summary

This patch attempts to fix the DomTree incremental insertion bug found here PR35969 .

When performing an insertion into a piece of unreachable CFG, we may find the same not at different levels. When this happens, the node can turn out to be affected when we find it starting from a node with a lower level in the tree. The level at which we start visitation affects if we consider a node affected or not.

This patch tracks the lowest level at which each node was visited during insertion and allows it to be visited multiple times, if it can cause it to be considered affected.

Diff Detail

Repository
rL LLVM

Event Timeline

kuhar created this revision.Jan 17 2018, 11:48 PM
brzycki added a subscriber: kuba.Jan 18 2018, 9:23 AM

Hi @kuba, I was unable to recreate the crash with the version of ddt-crash3.ll included in this patch. Here's my version of ddt-crash3.ll that fails before the patch. I've also verified this version passes after your patch. I'll take my time and review the real patch later today.

; RUN: opt < %s -jump-threading -disable-output -verify-dom-info
@global = external global i64, align 8

define void @f() {
bb:
  br label %bb1

bb1:
  %tmp = load i64, i64* @global, align 8
  %tmp2 = icmp eq i64 %tmp, 0
  br i1 %tmp2, label %bb27, label %bb3

bb3:
  %tmp4 = load i64, i64* @global, align 8
  %tmp5 = icmp eq i64 %tmp4, 0
  br i1 %tmp5, label %bb6, label %bb7

bb6:
  br label %bb7

bb7:
  %tmp8 = phi i1 [ true, %bb3 ], [ undef, %bb6 ]
  %tmp9 = select i1 %tmp8, i64 %tmp4, i64 0
  br i1 false, label %bb10, label %bb23

bb10:
  %tmp11 = load i64, i64* @global, align 8
  %tmp12 = icmp slt i64 %tmp11, 5
  br i1 %tmp12, label %bb13, label %bb17

bb13:
  br label %bb14

bb14:
  br i1 undef, label %bb15, label %bb16

bb15:
  unreachable

bb16:
  br label %bb10

bb17:
  br label %bb18

bb18:
  br i1 undef, label %bb22, label %bb13

bb19:
  br i1 undef, label %bb20, label %bb21

bb20:
  unreachable

bb21:
  br label %bb18

bb22:
  br label %bb23

bb23:
  br i1 undef, label %bb24, label %bb13

bb24:
  br i1 undef, label %bb26, label %bb25

bb25:
  br label %bb19

bb26:
  br label %bb1

bb27:
  br label %bb24
}

Your patch to GenericDomTreeConstruction.h passes ninja check-all on x86_64 as well as test-suite on x86_64. I used my version of ddt-crash3.ll posted above for the testing.

The changes to GenericDomTreeConstruction.h look good to me and I verified the new unit test fails without the patch. Other than my issue with ddt-crash3.ll the patch looks good.

kuhar updated this revision to Diff 130550.Jan 18 2018, 7:33 PM
kuhar edited the summary of this revision. (Show Details)
kuhar removed a subscriber: kuba.

Apply cosmetic fixes and add Brian's testcase.

The ddt-crash3.ll testcase makes sure we don't go into an infinite loop during visitation, while ddt-crash4.ll is more complicated and exercises the full crash reported in PR35969 .

brzycki accepted this revision.Jan 19 2018, 10:49 AM

LGTM. I've thrown everything I can think of to attempt to trigger a DT regression and found no asserts().

This revision is now accepted and ready to land.Jan 19 2018, 10:49 AM
This revision was automatically updated to reflect the committed changes.