<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 - OPT crashes with custom pass"
   href="https://bugs.llvm.org/show_bug.cgi?id=34573">34573</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>OPT crashes with custom pass
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>5.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>opt
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>berykubik@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=19145" name="attach_19145" title="module pass source code">attachment 19145</a> <a href="attachment.cgi?id=19145&action=edit" title="module pass source code">[details]</a></span>
module pass source code

Hello,

I'm trying to run a simple custom module pass that works fine in LLVM 3.8
through 4.0.1 but that crashes in LLVM 5.0.0.
Whether I run it through opt or load it in Clang, it crashes on a segfault.
I attached the source code of the pass.

The culprit lies in registering the pass using RegisterStandardPasses, if you
uncomment it, it should segfault in 5.0.0 (release).
If I leave it commented, it doesn't crash, but I need to use it to be able to
run the pass with clang using -Xclang -load, which works fine in LLVM 4.0.1 (I
don't know of any way how to run the pass with Clang without the
RegisterStandardPasses, it doesn't allow me to pass -tst as opt does).

This is how I compile the pass:
clang++ -std=c++14 -I<llvm-path>/include -fno-rtti -shared -fPIC pass.cpp -o
libpass.so

and then I run it using either
clang++ -Xclang -load -Xclang ./libpass.so test.cpp
or
opt -load ./libpass.so -tst test.bc

Both of them crash.
The test.cpp file is a barebones cpp file with just int main() { return 0; }.

Was there any change in LLVM 5 pass usage that could cause this to fail?
I didn't find anything in the documentation.</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>