[llvm-dev] Conflicts with custom passes

Kihong Heo via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 27 21:58:02 PDT 2019

Hi list,

I am making a simple custom pass that inserts print function calls for each instruction, so that compiled programs print out all llvm instructions on the dynamic path.
For example, (conceptually)

printf(“%s”, “x = x + 1”);  // inserted code
x = y + 1; // original code

But it seems that there are some conflicts with existing optimization paths. When I compile a program with the custom pass and -O2, it causes segmentation faults:

1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'Interprocedural Sparse Conditional Constant Propagation' on module '/src/libfuzzer/FuzzerCrossOver.cpp'.
#0 0x0000000001573cfa llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/local/bin/clang-8+0x1573cfa)
#1 0x00000000015721dc llvm::sys::RunSignalHandlers() (/usr/local/bin/clang-8+0x15721dc)
#2 0x0000000001572347 SignalHandler(int) (/usr/local/bin/clang-8+0x1572347)
#3 0x00007f8d810e7390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x0000000001497e69 (anonymous namespace)::SCCPSolver::getValueState(llvm::Value*) (.constprop.510) (/usr/local/bin/clang-8+0x1497e69)

I have two questions:
- Is there any guide line to write a custom pass to avoid such a conflict?
- Is there any existing framework to print out dynamic path in LLVM-IR format?

I would appreciate if some of you can give comments.


More information about the llvm-dev mailing list