<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - [WinEH] cleanupret to cleanuppad doesn't execute next cleanuppad unless optimized"
   href="https://llvm.org/bugs/show_bug.cgi?id=26361">26361</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[WinEH] cleanupret to cleanuppad doesn't execute next cleanuppad unless optimized
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Interprocedural Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>alex@crichton.co
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In the following IR, the function foo has two cleanup pads, but when compiled
without optimizations only one of them will be run. The return value of the
program should always be 2, but it will be 1 if optimizations are disabled. If
optimizations are enabled the `inc` function is inlined into the cleanup pads
which enables to bug to not be exhibited.



; ModuleID = 'foo.ll'
target triple = "i686-pc-windows-msvc"

@LOG = global i32 0

declare x86_stdcallcc void @RaiseException(i32, i32, i32, i8*)

declare i32 @_except_handler3(...)

define void @foo() personality i32 (...)* @_except_handler3 {
entry-block:
  invoke x86_stdcallcc void @RaiseException(i32 0, i32 0, i32 0, i8* null)
          to label %normal unwind label %unwind1

normal:                                           ; preds = %entry-block
  unreachable

unwind1:                                          ; preds = %entry-block
  %pad1 = cleanuppad within none []
  call void @inc() [ "funclet"(token %pad1) ]
  cleanupret from %pad1 unwind label %unwind2

unwind2:                                          ; preds = %unwind1
  %pad2 = cleanuppad within none []
  call void @inc() [ "funclet"(token %pad2) ]
  cleanupret from %pad2 unwind to caller
}

define void @inc() {
entry-block:
  %0 = load i32, i32* @LOG, align 4
  %1 = add i32 %0, 1
  store i32 %1, i32* @LOG, align 4
  ret void
}

define i32 @main(i32, i8**) personality i32 (...)* @_except_handler3 {
entry-block:
  invoke void @foo()
          to label %normal unwind label %catchswitch

normal:                                           ; preds = %entry-block
  ret i32 0

catchswitch:                                      ; preds = %entry-block
  %catchswitch1 = catchswitch within none [label %catchpad] unwind to caller

catchpad:                                         ; preds = %catchswitch
  %catchpad2 = catchpad within %catchswitch1 []
  catchret from %catchpad2 to label %check-return

check-return:                                     ; preds = %catchpad
  %2 = load i32, i32* @LOG, align 4
  ret i32 %2
}</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>