[PATCH] D71164: [InstCombine] Fix infinite loop due to bitcast <-> phi transforms

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 11 03:58:34 PST 2020


nikic added a comment.

Mostly reduced testcase triggering an infinite loop with this patch:

  %type_1 = type {}
  %type_2 = type {}
  %type_3 = type {}
  
  define dso_local void @SearchGalley() local_unnamed_addr {
  entry:
    br label %while.cond
  
  while.cond:                                       ; preds = %cond.end144, %entry
    %link.0 = phi %type_2* [ undef, %entry ], [ %cond145, %cond.end144 ]
    %os115 = bitcast %type_2* %link.0 to %type_3*
    %ou116 = getelementptr inbounds %type_3, %type_3* %os115, i32 0
    %os1117 = bitcast %type_3* %ou116 to %type_1*
    br label %for.cond
  
  for.cond:                                         ; preds = %while.cond
    switch i32 undef, label %sw.epilog [
      i32 120, label %sw.bb
      i32 122, label %sw.bb
      i32 121, label %sw.bb101
    ]
  
  sw.bb:                                            ; preds = %for.cond, %for.cond
    unreachable
  
  sw.bb101:                                         ; preds = %for.cond
    unreachable
  
  sw.epilog:                                        ; preds = %for.cond
    br i1 undef, label %cond.true133, label %cond.false138
  
  cond.true133:                                     ; preds = %sw.epilog
    %0 = load %type_2*, %type_2** undef, align 8
    br label %cond.end144
  
  cond.false138:                                    ; preds = %sw.epilog
    %1 = load %type_2*, %type_2** undef, align 8
    br label %cond.end144
  
  cond.end144:                                      ; preds = %cond.false138, %cond.true133
    %cond145 = phi %type_2* [ %0, %cond.true133 ], [ %1, %cond.false138 ]
    br label %while.cond
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71164





More information about the llvm-commits mailing list