Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in MSP430 DAG->DAG Pattern Instruction Selection #72

Closed
dmikushin opened this issue Dec 28, 2018 · 5 comments · Fixed by #77
Closed

Crash in MSP430 DAG->DAG Pattern Instruction Selection #72

dmikushin opened this issue Dec 28, 2018 · 5 comments · Fixed by #77

Comments

@dmikushin
Copy link
Contributor

gcc_personality_v0-ae2857.zip

[  0%] Building C object lib/builtins/CMakeFiles/clang_rt.builtins-msp430.dir/gcc_personality_v0.c.o
clang-8: /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:6425: llvm::SDValue llvm::SelectionDAG::getLoad(llvm::ISD::MemIndexedMode, llvm::ISD::LoadExtType, llvm::EVT, const llvm::SDLoc&, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::EVT, llvm::MachineMemOperand*): Assertion `MemVT.getScalarType().bitsLT(VT.getScalarType()) && "Should only be an extending load, not truncating!"' failed.
Stack dump:
0.	Program arguments: /home/marcusmae/acctek/msp430-clang-newlib/install/bin/clang-8 -cc1 -triple msp430-unknown-unknown -emit-obj -mrelax-all -disable-free -main-file-name gcc_personality_v0.c -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -nostdsysteminc -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -momit-leaf-frame-pointer -coverage-notes-file /home/marcusmae/acctek/msp430-clang-newlib/msp430-compiler-rt/build/lib/builtins/CMakeFiles/clang_rt.builtins-msp430.dir/gcc_personality_v0.c.gcno -resource-dir /home/marcusmae/acctek/msp430-clang-newlib/install/lib/clang/8.0.0 -D VISIBILITY_HIDDEN -internal-isystem /home/marcusmae/acctek/msp430-clang-newlib/install/bin/../msp430-elf/include -Wall -Wno-unused-parameter -std=c11 -fdebug-compilation-dir /home/marcusmae/acctek/msp430-clang-newlib/msp430-compiler-rt/build/lib/builtins -ferror-limit 19 -fmessage-length 144 -fvisibility hidden -fno-builtin -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o CMakeFiles/clang_rt.builtins-msp430.dir/gcc_personality_v0.c.o -x c /home/marcusmae/acctek/msp430-clang-newlib/msp430-compiler-rt/lib/builtins/gcc_personality_v0.c -faddrsig 
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '/home/marcusmae/acctek/msp430-clang-newlib/msp430-compiler-rt/lib/builtins/gcc_personality_v0.c'.
4.	Running pass 'MSP430 DAG->DAG Pattern Instruction Selection' on function '@readEncodedPointer'
#0 0x00007f37fc72d2d3 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/Support/Unix/Signals.inc:495:0
#1 0x00007f37fc72d366 PrintStackTraceSignalHandler(void*) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/Support/Unix/Signals.inc:559:0
#2 0x00007f37fc72b08c llvm::sys::RunSignalHandlers() /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/Support/Signals.cpp:67:0
#3 0x00007f37fc72ccf5 SignalHandler(int) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/Support/Unix/Signals.inc:358:0
#4 0x00007f37f9112f20 (/lib/x86_64-linux-gnu/libc.so.6+0x3ef20)
#5 0x00007f37f9112e97 gsignal /build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#6 0x00007f37f9114801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
#7 0x00007f37f910439a __assert_fail_base /build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
#8 0x00007f37f9104412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
#9 0x00007f37f85009d5 llvm::SelectionDAG::getLoad(llvm::ISD::MemIndexedMode, llvm::ISD::LoadExtType, llvm::EVT, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::EVT, llvm::MachineMemOperand*) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:6424:0
#10 0x00007f37f850087f llvm::SelectionDAG::getLoad(llvm::ISD::MemIndexedMode, llvm::ISD::LoadExtType, llvm::EVT, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::MachinePointerInfo, llvm::EVT, unsigned int, llvm::MachineMemOperand::Flags, llvm::AAMDNodes const&, llvm::MDNode const*) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:6411:0
#11 0x00007f37f85011ea llvm::SelectionDAG::getExtLoad(llvm::ISD::LoadExtType, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::MachinePointerInfo, llvm::EVT, unsigned int, llvm::MachineMemOperand::Flags, llvm::AAMDNodes const&) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:6488:0
#12 0x00007f37f83a25fb (anonymous namespace)::SelectionDAGLegalize::ExpandNode(llvm::SDNode*) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:3496:0
#13 0x00007f37f838e717 (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1226:0
#14 0x00007f37f83aa9d0 llvm::SelectionDAG::Legalize() /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:4599:0
#15 0x00007f37f853b0c0 llvm::SelectionDAGISel::CodeGenAndEmitDAG() /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:863:0
#16 0x00007f37f8541667 llvm::SelectionDAGISel::FinishBasicBlock() /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:2082:0
#17 0x00007f37f8540048 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1796:0
#18 0x00007f37f8538738 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:472:0
#19 0x00007f380071c715 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/CodeGen/MachineFunctionPass.cpp:74:0
#20 0x00007f37ff9e2eb4 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/IR/LegacyPassManager.cpp:1644:0
#21 0x00007f37ff9e312b llvm::FPPassManager::runOnModule(llvm::Module&) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/IR/LegacyPassManager.cpp:1679:0
#22 0x00007f37ff9e352c (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/IR/LegacyPassManager.cpp:1744:0
#23 0x00007f37ff9e3d4f llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/IR/LegacyPassManager.cpp:1857:0
#24 0x00007f37ff9e3f7f llvm::legacy::PassManager::run(llvm::Module&) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/lib/IR/LegacyPassManager.cpp:1889:0
#25 0x00007f37fa387e44 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:871:0
#26 0x00007f37fa38b1c8 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:1300:0
#27 0x00007f37fa7c51d1 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:293:0
#28 0x00007f37f2dbd1e6 clang::ParseAST(clang::Sema&, bool, bool) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/tools/clang/lib/Parse/ParseAST.cpp:177:0
#29 0x00007f37f9bd0887 clang::ASTFrontendAction::ExecuteAction() /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:1018:0
#30 0x00007f37fa7c1b88 clang::CodeGenAction::ExecuteAction() /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:1045:0
#31 0x00007f37f9bd0278 clang::FrontendAction::Execute() /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:921:0
#32 0x00007f37f9b45ec0 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:969:0
#33 0x00007f3802ac9f3e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:267:0
#34 0x000055a038e999c0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/tools/clang/tools/driver/cc1_main.cpp:219:0
#35 0x000055a038e8ebf3 ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/tools/clang/tools/driver/driver.cpp:310:0
#36 0x000055a038e8f8d5 main /home/marcusmae/acctek/msp430-clang-newlib/msp430-clang/src/llvm/tools/clang/tools/driver/driver.cpp:382:0
#37 0x00007f37f90f5b97 __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#38 0x000055a038e8c5da _start (/home/marcusmae/acctek/msp430-clang-newlib/install/bin/clang-8+0x3e5da)
clang-8: error: unable to execute command: Aborted (core dumped)
clang-8: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 8.0.0 
Target: msp430-unknown-unknown
Thread model: posix
InstalledDir: /home/marcusmae/acctek/msp430-clang-newlib/install/bin
clang-8: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang-8: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-8: note: diagnostic msg: /tmp/gcc_personality_v0-ae2857.c
clang-8: note: diagnostic msg: /tmp/gcc_personality_v0-ae2857.sh
clang-8: note: diagnostic msg: 

********************
@mskvortsov
Copy link
Contributor

Here is a small repro, run with llc -relocation-model=pic

target datalayout = "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16"
target triple = "msp430-elf"

define i16 @foo(i8** %data, i8 zeroext %encoding) noinline optnone {
entry:
  %encoding.addr = alloca i8, align 1
  store i8 %encoding, i8* %encoding.addr, align 1

  %tmp3 = load i8, i8* %encoding.addr, align 1
  %conv2 = zext i8 %tmp3 to i16
  %and = and i16 %conv2, 15

  switch i16 %and, label %sw.default [
    i16 0, label %sw.bb1
    i16 4, label %sw.bb1
    i16 10, label %sw.bb1
    i16 11, label %sw.bb2
  ]

sw.bb1:
  ret i16 1

sw.bb2:
  ret i16 2

sw.default:
  unreachable
}

@asl
Copy link
Contributor

asl commented Jan 9, 2019

We should not allow / disable PIC

@dmikushin
Copy link
Contributor Author

Disable dynamic completely, or just disable PIC (e.g. dynamic-no-pic) ?

@asl
Copy link
Contributor

asl commented Jan 9, 2019

I don't think we will ever have shared libraries / position-independent binaries. So, all non-static modes should be just ignored

@dmikushin
Copy link
Contributor Author

OK, I've verified that -shared is already ignored, so PIC/PIE settings is the only thing to disable. I've submitted chbessonova#3 to @chbessonova , as the msp430-toolchain tree is apparently still on her branch. With this patch this crash no longer happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants