[llvm-bugs] [Bug 26361] New: [WinEH] cleanupret to cleanuppad doesn't execute next cleanuppad unless optimized

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 28 14:46:13 PST 2016


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

            Bug ID: 26361
           Summary: [WinEH] cleanupret to cleanuppad doesn't execute next
                    cleanuppad unless optimized
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: alex at crichton.co
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

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
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160128/c21dafba/attachment-0001.html>


More information about the llvm-bugs mailing list