Using opt tool

Hello,

I am compiling an OpenMP program using clang

clang -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -O3 -fopenmp -emit-llvm -S -c test1.c -o test1.ll

However when I try to compiler test1.ll using opt
$ opt -S -O3 test1.ll

Stack dump:
0. Program arguments: opt -S -O3 test1.ll

  1. Running pass ‘CallGraph Pass Manager’ on module ‘test1.ll’.
    0 opt 0x00000001010ce9b5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
    1 opt 0x00000001010cd878 llvm::sys::RunSignalHandlers() + 248
    2 opt 0x00000001010cefcc SignalHandler(int) + 268
    3 libsystem_platform.dylib 0x00007fff71f715fd _sigtramp + 29
    4 libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338604145184
    5 opt 0x0000000100b87a32 (anonymous namespace)::OpenMPOpt::run() + 4162
    6 opt 0x0000000100b9134b (anonymous namespace)::OpenMPOptLegacyPass::runOnSCC(llvm::CallGraphSCC&) + 651
    7 opt 0x00000001003e63c4 (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) + 1172
    8 opt 0x0000000100a35db9 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 825
    9 opt 0x00000001000aed32 main + 13138
    10 libdyld.dylib 0x00007fff71d78cc9 start + 1
    11 libdyld.dylib 0x0000000000000004 start + 18446603338606211900
    Segmentation fault: 11

Thanks,

Hi Abid,

I’m not sure you can get much help without more details. Is it the released version or are you trying to make changes to OpenMPOpt?

-debug option can be helpful.

–stefan

Thanks, Stefan, Yes I am trying to make changes in OpenOpt.

I will look into it. Clang and opt use the same pipeline. So why it works for clang and not for opt.

Thanks, Stefan, Yes I am trying to make changes in OpenOpt.

I will look into it. Clang and opt use the same pipeline. So why it works
for clang and not for opt.

When you generated your test.ll you did run O3. Then you run opt
with O3 on the result. So, the same pipeline but different inputs.
Also, it is not trivial to get the exact same pipeline between clang
and opt. What you might want to do is:

clang -emit-llvm -S -c -O3 -mllvm -disable-llvm-optzns test.c

which should give you a test.ll that is very close to the one at the
beginning of clangs O3 pipeline. Note that the above command actually
doesn't run O3 passes but just pretends to ensure the frontend generates
the same IR.

To debug your error, maybe start with a debug build of LLVM.

~ Johannes