[llvm-bugs] [Bug 24797] New: clang crashes on code with inlined assembly on x86_64-linux-gnu (as well as OS X)

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Sep 12 17:27:58 PDT 2015


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

            Bug ID: 24797
           Summary: clang crashes on code with inlined assembly on
                    x86_64-linux-gnu (as well as OS X)
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The current clang trunk crashes when compiling the following code in both
32-bit and 64-bit modes on x86_64-linux-gnu.  

It also affects MacOS X and seems to crash every release of clang from as early
as 2.9. 


$ clang-trunk -v
clang version 3.8.0 (trunk 247514)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/tools/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.2
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.1.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.1.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$ 
$ gcc-trunk -Wall -Wextra -pedantic -std=c99 -c small.c             
$ 
$ clang-trunk -c small.c
clang: /tmp/llvm/tools/clang/lib/CodeGen/CGStmt.cpp:1921: void
clang::CodeGen::CodeGenFunction::EmitAsmStmt(const clang::AsmStmt &): Assertion
`OutputTy->isFloatingPointTy() && "Unexpected output type"' failed.
#0 0x2dcb8ed llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang+0x2dcb8ed)
#1 0x2dcaf76 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang+0x2dcaf76)
#2 0x2dcd0ee (/usr/local/clang-trunk/bin/clang+0x2dcd0ee)
#3 0x7f654525a340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x7f65441f5cc9 gsignal
/build/buildd/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x7f65441f90d8 abort /build/buildd/eglibc-2.19/stdlib/abort.c:91:0
#6 0x7f65441eeb86 __assert_fail_base
/build/buildd/eglibc-2.19/assert/assert.c:92:0
#7 0x7f65441eec32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0xa09ded clang::CodeGen::CodeGenFunction::EmitAsmStmt(clang::AsmStmt const&)
(/usr/local/clang-trunk/bin/clang+0xa09ded)
#9 0xa014a3 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*)
(/usr/local/clang-trunk/bin/clang+0xa014a3)
#10 0xa0b8dc
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/usr/local/clang-trunk/bin/clang+0xa0b8dc)
#11 0xa36f71 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/usr/local/clang-trunk/bin/clang+0xa36f71)
#12 0xa49035
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/usr/local/clang-trunk/bin/clang+0xa49035)
#13 0xa4578a
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/usr/local/clang-trunk/bin/clang+0xa4578a)
#14 0xa4ac35 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*)
(/usr/local/clang-trunk/bin/clang+0xa4ac35)
#15 0x9be7ef (/usr/local/clang-trunk/bin/clang+0x9be7ef)
#16 0x9b2a67 (/usr/local/clang-trunk/bin/clang+0x9b2a67)
#17 0xc38ec3 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang+0xc38ec3)
#18 0x7750f5 clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang+0x7750f5)
#19 0x74247c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang+0x74247c)
#20 0x7221d7 clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang+0x7221d7)
#21 0x718225 cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
(/usr/local/clang-trunk/bin/clang+0x718225)
#22 0x72086f main (/usr/local/clang-trunk/bin/clang+0x72086f)
#23 0x7f65441e0ec5 __libc_start_main
/build/buildd/eglibc-2.19/csu/libc-start.c:321:0
#24 0x717cb9 _start (/usr/local/clang-trunk/bin/clang+0x717cb9)
Stack dump:
0.    Program arguments: /usr/local/clang-trunk/bin/clang -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
small.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -target-linker-version 2.24
-dwarf-column-info -coverage-file /data2/small.c -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/3.8.0 -internal-isystem
/usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/3.8.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdebug-compilation-dir /data2
-ferror-limit 19 -fmessage-length 234 -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -o small.o -x c small.c 
1.    <eof> parser at end of file
2.    small.c:2:1: LLVM IR generation of declaration 'foo'
3.    small.c:2:1: Generating code for declaration 'foo'
clang: error: unable to execute command: Aborted
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.8.0 (trunk 247514)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/tools/bin
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang: note: diagnostic msg: 
********************

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

********************
$ 


-------------------------------------


void
foo (void)
{
  unsigned char e[16];
  unsigned long a, b, c;
  __asm__ __volatile__ ("":"=d" (a), "=&c" (c), "=&mr" (e),
            "=&a" (b):"0" (-1U), "mr" (e), "1" (128 >> 5),
            "2" (e), "3" (-1U));
}

-- 
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/20150913/6ad4850e/attachment.html>


More information about the llvm-bugs mailing list