[llvm-dev] Segmentation fault in opt with -x86-codegen

raghesh via llvm-dev llvm-dev at lists.llvm.org
Tue Sep 10 20:31:15 PDT 2019


Hi All,

We are observing a segmentation fault in opt with -x86-codegen switch. This
happens with any general llvm-IR. Please find attached a simple testcase.
It can be reproduced with the following.

opt -S -o a.out.ll a.ll -x86-codegen

The traces of the error is as follows.

Stack dump:
0.      Program arguments:
/home/raghesh/code/mirror/llvm-project/build/bin/opt -S -o a.out.ll a.ll
-x86-codegen
 #0 0x00007ff5339d728a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/raghesh/code/mirror/llvm-project/build/bin/../lib/libLLVM-10svn.so+0x76528a)
 #1 0x00007ff5339d4f64 llvm::sys::RunSignalHandlers()
(/home/raghesh/code/mirror/llvm-project/build/bin/../lib/libLLVM-10svn.so+0x762f64)
 #2 0x00007ff5339d50a2 SignalHandler(int)
(/home/raghesh/code/mirror/llvm-project/build/bin/../lib/libLLVM-10svn.so+0x7630a2)
 #3 0x00007ff53291ef20 (/lib/x86_64-linux-gnu/libc.so.6+0x3ef20)
 #4 0x00007ff533d86080
llvm::MachineModuleInfo::MachineModuleInfo(llvm::LLVMTargetMachine const*)
(/home/raghesh/code/mirror/llvm-project/build/bin/../lib/libLLVM-10svn.so+0xb14080)
 #5 0x00007ff533d86178 llvm::Pass*
llvm::callDefaultCtor<llvm::MachineModuleInfo>()
(/home/raghesh/code/mirror/llvm-project/build/bin/../lib/libLLVM-10svn.so+0xb14178)
 #6 0x00007ff533b0c83d llvm::PMTopLevelManager::schedulePass(llvm::Pass*)
(/home/raghesh/code/mirror/llvm-project/build/bin/../lib/libLLVM-10svn.so+0x89a83d)
 #7 0x00007ff533b0c9a3 llvm::PMTopLevelManager::schedulePass(llvm::Pass*)
(/home/raghesh/code/mirror/llvm-project/build/bin/../lib/libLLVM-10svn.so+0x89a9a3)
 #8 0x0000557729456ac4 main
(/home/raghesh/code/mirror/llvm-project/build/bin/opt+0x1dac4)
 #9 0x00007ff532901b97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#10 0x000055772945795a _start
(/home/raghesh/code/mirror/llvm-project/build/bin/opt+0x1e95a)
Segmentation fault (core dumped)

With a preliminary analysis, it can be seen that MachineModuleInfo pass
which is a "Required" dependency of MachineFunction pass invoked by
-x86-codegen.Here, the MachineModuleInfo is created through the call to
llvm::callDefaultCtor<llvm::MachineModuleInfo>(). However, the default
constructor of MachineModuleInfo expects a valid pointer to
LLVMTargetMachine, which happens to be nullptr in this case and triggers
seg fault when accessed.

It would be great if someone could have a look at it and provide or suggest
the proper fix.

Regards,
------------------------------
Raghesh Aloor
Sr. Software Engineer
AMD India Pvt. Ltd.
Bengaluru.
------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190911/6660c03e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: a.ll
Type: application/octet-stream
Size: 1693 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190911/6660c03e/attachment.obj>


More information about the llvm-dev mailing list