[llvm-commits] Edge dominance in the presence of multiple edges between two BB

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu Aug 9 21:20:11 PDT 2012


Working on bug 13307 I found a very interesting corner case:

define void @f5(i32 %x) {
bb0:
  %y1 = invoke i32 @g() to label %bb1 unwind label %bb1
bb1:
  %y2 = phi i32 [%y1, %bb0], [%y1, %bb0]
  %y3 = landingpad i32 personality i32 ()* @g
          cleanup
  ret void
}

My understanding is that it is invalid, as %y1 is used in the unwind
edge of the invoke. We currently accept it. We used to accept it
before 161429 too. The attached patch fixes it. With this stricter
interpretation gvn, once converted to use the new dominance functions,
should them be able to transform

define i32 @f(i32 %i) {
bb0:
  switch i32 %i, label %bb1 [
    i32 1, label %bb2
    i32 2, label %bb2
  ]
bb1:
  br label %bb2
bb2:
  %r = phi i32 [ %i, %bb0 ], [ %i, %bb0 ], [ 5, %bb1 ]
  ret i32 %r
}

into

define i32 @f(i32 %i) {
bb0:
  switch i32 %i, label %bb1 [
    i32 1, label %bb2
    i32 2, label %bb2
  ]
bb1:
  br label %bb2
bb2:
  %r = phi i32 [ 1, %bb0 ], [ 2, %bb0 ], [ 5, %bb1 ]
  ret i32 %r
}

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 4375 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120810/290759a7/attachment.obj>


More information about the llvm-commits mailing list