[llvm-bugs] [Bug 25634] New: clang crashes on valid code with inlined assembly on x86_64-linux-gnu

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Nov 25 07:06:49 PST 2015


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

            Bug ID: 25634
           Summary: clang crashes on valid code with inlined assembly on
                    x86_64-linux-gnu
           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 on
x86_64-linux-gnu.  

It also affects 3.2 and later, and thus a regression from 3.1. 


$ clang-trunk -v
clang version 3.8.0 (trunk 254011)
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.4
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
$ 
$ clang-3.1 -c small.c
$ gcc-trunk -c small.c
$ 
$ clang-trunk -c small.c
Instruction uses an allocated register
UNREACHABLE executed at /tmp/llvm/lib/CodeGen/RegAllocFast.cpp:361!
#0 0x0000000003133c95 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang+0x3133c95)
#1 0x0000000003131706 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang+0x3131706)
#2 0x0000000003131916 (/usr/local/clang-trunk/bin/clang+0x3131916)
#3 0x00007fb67e796340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007fb67d731cc9 gsignal
/build/buildd/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007fb67d7350d8 abort /build/buildd/eglibc-2.19/stdlib/abort.c:91:0
#6 0x0000000003115abc (/usr/local/clang-trunk/bin/clang+0x3115abc)
#7 0x000000000291d58b (/usr/local/clang-trunk/bin/clang+0x291d58b)
#8 0x00000000029239d4 (/usr/local/clang-trunk/bin/clang+0x29239d4)
#9 0x0000000002924e2f (/usr/local/clang-trunk/bin/clang+0x2924e2f)
#10 0x000000000309f99f llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang+0x309f99f)
#11 0x000000000309f9db llvm::FPPassManager::runOnModule(llvm::Module&)
(/usr/local/clang-trunk/bin/clang+0x309f9db)
#12 0x00000000030a15a7 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang+0x30a15a7)
#13 0x0000000000bc6ed8 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::StringRef, llvm::Module*, clang::BackendAction,
llvm::raw_pwrite_stream*) (/usr/local/clang-trunk/bin/clang+0xbc6ed8)
#14 0x0000000000ba3488 (/usr/local/clang-trunk/bin/clang+0xba3488)
#15 0x0000000000e0a552 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang+0xe0a552)
#16 0x0000000000ba5fa2 clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang+0xba5fa2)
#17 0x000000000098e036 clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang+0x98e036)
#18 0x00000000009632fe
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang+0x9632fe)
#19 0x000000000094453c
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang+0x94453c)
#20 0x000000000093c350 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang+0x93c350)
#21 0x00000000009222f8 main (/usr/local/clang-trunk/bin/clang+0x9222f8)
#22 0x00007fb67d71cec5 __libc_start_main
/build/buildd/eglibc-2.19/csu/libc-start.c:321:0
#23 0x000000000093a9dd _start (/usr/local/clang-trunk/bin/clang+0x93a9dd)
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 149 -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -o small.o -x c small.c 
1.    <eof> parser at end of file
2.    Code generation
3.    Running pass 'Function Pass Manager' on module 'small.c'.
4.    Running pass 'Fast Register Allocator' on function '@fn1'
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.8.0 (trunk 254011)
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-260937.c
clang: note: diagnostic msg: /tmp/small-260937.sh
clang: note: diagnostic msg: 

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


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


void 
fn1 ()
{
  register int edi asm ("edi");

  asm ("movl\t%2, %0\n\tmovl\t%2, %1"
       : "=r" (edi), "=r" (edi)
       : "i" (0xdeadbeef));
}

-- 
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/20151125/8a959983/attachment.html>


More information about the llvm-bugs mailing list