[llvm-bugs] [Bug 34573] New: OPT crashes with custom pass

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 12 03:38:08 PDT 2017


            Bug ID: 34573
           Summary: OPT crashes with custom pass
           Product: tools
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: opt
          Assignee: unassignedbugs at nondot.org
          Reporter: berykubik at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 19145
  --> https://bugs.llvm.org/attachment.cgi?id=19145&action=edit
module pass source code


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

and then I run it using either
clang++ -Xclang -load -Xclang ./libpass.so test.cpp
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.

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/20170912/291630f7/attachment.html>

More information about the llvm-bugs mailing list