[llvm-bugs] [Bug 41748] New: clang crashes with 'Unknown mismatch!' on SelectionDAGBuilder.cpp:325, when inline asm uses '=y' constraint with 32-bit var

via llvm-bugs llvm-bugs at lists.llvm.org
Sun May 5 04:56:18 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41748

            Bug ID: 41748
           Summary: clang crashes with 'Unknown mismatch!' on
                    SelectionDAGBuilder.cpp:325, when inline asm uses '=y'
                    constraint with 32-bit var
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: mgorny at gentoo.org
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 21894
  --> https://bugs.llvm.org/attachment.cgi?id=21894&action=edit
test-7c03bb.cpp

Consider the following reduced test case:

  int main() {
    unsigned int x;

    asm volatile(
      "movd    %%eax, %0"
      : "=y"(x)
      :
      :
    );

    return 0;
  }

The inline asm snippet is supposed to return a 32-bit value through 64-bit MMX
register.  GCC seems to cope with it but clang crashes while compiling it:

Unknown mismatch!
UNREACHABLE executed at
/home/mgorny/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:325!
Stack dump:
0.      Program arguments: /home/mgorny/llvm-project/build-rel/bin/clang-9 -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name test.cpp -mrelocation-model static -mthread-model posix
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info
-debugger-tuning=gdb -resource-dir
/home/mgorny/llvm-project/build-rel/lib/clang/9.0.0 -internal-isystem
/usr/lib/gcc/x86_64-pc-linux-gnu/7.4.0/include/g++-v7 -internal-isystem
/usr/lib/gcc/x86_64-pc-linux-gnu/7.4.0/include/g++-v7/x86_64-pc-linux-gnu
-internal-isystem
/usr/lib/gcc/x86_64-pc-linux-gnu/7.4.0/include/g++-v7/backward
-internal-isystem /usr/local/include -internal-isystem
/home/mgorny/llvm-project/build-rel/lib/clang/9.0.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O0
-fdeprecated-macro -fdebug-compilation-dir /home/mgorny/llvm-project/build-rel
-ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -o /tmp/test-7aecaf.o -x c++ test.cpp 
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'test.cpp'.
4.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@main'
 #0 0x00007f6ac87e5bc5 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/mgorny/llvm-project/llvm/lib/Support/Unix/Signals.inc:494:0
 #1 0x00007f6ac87e5c58 PrintStackTraceSignalHandler(void*)
/home/mgorny/llvm-project/llvm/lib/Support/Unix/Signals.inc:558:0
 #2 0x00007f6ac87e3c58 llvm::sys::RunSignalHandlers()
/home/mgorny/llvm-project/llvm/lib/Support/Signals.cpp:68:0
 #3 0x00007f6ac87e5618 SignalHandler(int)
/home/mgorny/llvm-project/llvm/lib/Support/Unix/Signals.inc:357:0
 #4 0x00007f6ac7564520 __restore_rt (/lib64/libpthread.so.0+0x14520)
 #5 0x00007f6ac3816c8b raise
/var/tmp/portage/sys-libs/glibc-2.28-r5/work/glibc-2.28/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #6 0x00007f6ac3818471 abort
/var/tmp/portage/sys-libs/glibc-2.28-r5/work/glibc-2.28/stdlib/abort.c:81:0
 #7 0x00007f6ac8694893 bindingsErrorHandler(void*,
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&, bool)
/home/mgorny/llvm-project/llvm/lib/Support/ErrorHandling.cpp:230:0
 #8 0x00007f6ac2528508 getCopyFromParts(llvm::SelectionDAG&, llvm::SDLoc
const&, llvm::SDValue const*, unsigned int, llvm::MVT, llvm::EVT, llvm::Value
const*, llvm::Optional<unsigned int>, llvm::Optional<llvm::ISD::NodeType>)
/home/mgorny/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:326:0
 #9 0x00007f6ac252c0e1 llvm::RegsForValue::getCopyFromRegs(llvm::SelectionDAG&,
llvm::FunctionLoweringInfo&, llvm::SDLoc const&, llvm::SDValue&,
llvm::SDValue*, llvm::Value const*) const
/home/mgorny/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:867:0
#10 0x00007f6ac255d7c1
llvm::SelectionDAGBuilder::visitInlineAsm(llvm::ImmutableCallSite)
/home/mgorny/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:8322:0
#11 0x00007f6ac25594f4 llvm::SelectionDAGBuilder::visitCall(llvm::CallInst
const&)
/home/mgorny/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:7418:0
#12 0x00007f6ac252dc2e llvm::SelectionDAGBuilder::visit(unsigned int,
llvm::User const&)
/home/mgorny/llvm-project/llvm/include/llvm/IR/Instruction.def:209:0
#13 0x00007f6ac252d552 llvm::SelectionDAGBuilder::visit(llvm::Instruction
const&)
/home/mgorny/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:1082:0
#14 0x00007f6ac2605a3f
llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction,
true, false, void>, false, true>,
llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true,
false, void>, false, true>, bool&)
/home/mgorny/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:686:0
#15 0x00007f6ac260b39c
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
/home/mgorny/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1754:0
#16 0x00007f6ac26047d0
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
/home/mgorny/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:497:0
#17 0x00007f6acf71c2e3 (anonymous
namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
/home/mgorny/llvm-project/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:192:0
#18 0x00007f6acc91b8ef
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
/home/mgorny/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:73:0
#19 0x00007f6acbba8840 llvm::FPPassManager::runOnFunction(llvm::Function&)
/home/mgorny/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1648:0
#20 0x00007f6acbba8b31 llvm::FPPassManager::runOnModule(llvm::Module&)
/home/mgorny/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1685:0
#21 0x00007f6acbba8f87 (anonymous
namespace)::MPPassManager::runOnModule(llvm::Module&)
/home/mgorny/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1752:0
#22 0x00007f6acbba9747 llvm::legacy::PassManagerImpl::run(llvm::Module&)
/home/mgorny/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1865:0
#23 0x00007f6acbba9939 llvm::legacy::PassManager::run(llvm::Module&)
/home/mgorny/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1897:0
#24 0x00007f6ac5f28455 (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
/home/mgorny/llvm-project/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:892:0
#25 0x00007f6ac5f2c610 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/mgorny/llvm-project/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:1452:0
#26 0x00007f6ac635f8b9
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
/home/mgorny/llvm-project/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:300:0
#27 0x00007f6abb32a776 clang::ParseAST(clang::Sema&, bool, bool)
/home/mgorny/llvm-project/llvm/tools/clang/lib/Parse/ParseAST.cpp:178:0
#28 0x00007f6ac5360a89 clang::ASTFrontendAction::ExecuteAction()
/home/mgorny/llvm-project/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:1035:0
#29 0x00007f6ac635c2c5 clang::CodeGenAction::ExecuteAction()
/home/mgorny/llvm-project/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:1057:0
#30 0x00007f6ac5360478 clang::FrontendAction::Execute()
/home/mgorny/llvm-project/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:938:0
#31 0x00007f6ac52e73a6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/mgorny/llvm-project/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:945:0
#32 0x00007f6ac4dc42cc
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/mgorny/llvm-project/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:273:0
#33 0x00005600f7f9d49f cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
/home/mgorny/llvm-project/llvm/tools/clang/tools/driver/cc1_main.cpp:225:0
#34 0x00005600f7f92b5b ExecuteCC1Tool(llvm::ArrayRef<char const*>,
llvm::StringRef)
/home/mgorny/llvm-project/llvm/tools/clang/tools/driver/driver.cpp:309:0
#35 0x00005600f7f9324c main
/home/mgorny/llvm-project/llvm/tools/clang/tools/driver/driver.cpp:381:0
#36 0x00007f6ac3801e77 __libc_start_main
/var/tmp/portage/sys-libs/glibc-2.28-r5/work/glibc-2.28/csu/../csu/libc-start.c:342:0
#37 0x00005600f7f9132a _start
/var/tmp/portage/sys-libs/glibc-2.28-r5/work/glibc-2.28/csu/../sysdeps/x86_64/start.S:122:0
clang-9: error: unable to execute command: Aborted
clang-9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 9.0.0 (https://github.com/llvm/llvm-project
5b05f20a3a538a6f87f67220a1eea77d14175597)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/mgorny/llvm-project/build-rel/./bin
clang-9: 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-9: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-9: note: diagnostic msg: /tmp/test-7c03bb.cpp
clang-9: note: diagnostic msg: /tmp/test-7c03bb.sh
clang-9: note: diagnostic msg: 

********************

-- 
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/20190505/3f00d135/attachment.html>


More information about the llvm-bugs mailing list