<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - The 'cleanuppad' IR instruction doesn't work on Linux"
   href="https://bugs.llvm.org/show_bug.cgi?id=45527">45527</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>The 'cleanuppad' IR instruction doesn't work on Linux
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>10.0
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>Core LLVM classes
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>akornilov.82@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=23347" name="attach_23347" title="ex-cleanuppad.ll">attachment 23347</a> <a href="attachment.cgi?id=23347&action=edit" title="ex-cleanuppad.ll">[details]</a></span>
ex-cleanuppad.ll

I have prepared this simple example of using cleanup for Linux with 'old'
instruction 'landingpad':
; ModuleID = 'ex-landingpad.bc'
source_filename = "ExTest.cpp"

@_ZTIi = external constant i8*

declare i8* @__cxa_allocate_exception(i64)

declare void @__cxa_throw(i8*, i8*, i8*)

declare void @__jetvm_backtrace(i32)

define i32 @sum(i32 %0, i32 %1) {
  %3 = call i8* @__cxa_allocate_exception(i64 4)
  store i8 33, i8* %3
  call void @__cxa_throw(i8* %3, i8* bitcast (i8** @_ZTIi to i8*), i8* null)
  unreachable
}

; Function Attrs: noinline optnone uwtable
define i32 @calc() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0
to i8*) {
  %1 = alloca i8*
  %2 = invoke i32 @sum(i32 99, i32 77)
          to label %3 unwind label %4

3:                                                ; preds = %0
  ret i32 %2

4:                                                ; preds = %0
  %5 = landingpad { i8*, i32 }
          cleanup

  ; Some cleanup actions
  resume { i8*, i32 } %5
}

declare i32 @__gxx_personality_v0(...)

attributes #0 = { noinline optnone uwtable }


It works fine on Linux. After that I have tried to use 'new' instruction
'cleanuppad':

; ModuleID = 'ex-cleanuppad.bc'
source_filename = "ExTest.cpp"

@_ZTIi = external constant i8*

declare i8* @__cxa_allocate_exception(i64)

declare void @__cxa_throw(i8*, i8*, i8*)

declare void @__jetvm_backtrace(i32)

define i32 @sum(i32 %0, i32 %1) {
  %3 = call i8* @__cxa_allocate_exception(i64 4)
  store i8 33, i8* %3
  call void @__cxa_throw(i8* %3, i8* bitcast (i8** @_ZTIi to i8*), i8* null)
  unreachable
}

; Function Attrs: noinline optnone uwtable
define i32 @calc() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0
to i8*) {
  %1 = invoke i32 @sum(i32 99, i32 77)
          to label %2 unwind label %3

2:                                                ; preds = %0
  ret i32 %1

3:                                                ; preds = %0
  %4 = cleanuppad within none []

  ; Some cleanup actions
  cleanupret from %4 unwind to caller
}

declare i32 @__gxx_personality_v0(...)

attributes #0 = { noinline optnone uwtable }

But application crashes in this case.
I obtained assembler versions (x86_64) of IR by LLC and have noticed that in
'landingpad' case instruction 'resume' transformed into _Unwind_Resume. But for
'cleanupret' just 'retq' generated.

All files are attached to this ticket.</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>