Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

clang crashes on valid code at -O1 and above: Assertion `OutputTy->isFloatingPointTy() && "Unexpected output type"' failed #27346

Open Quuxplusone opened 8 years ago

Quuxplusone commented 8 years ago
Bugzilla Link PR27347
Status NEW
Importance P normal
Reported by Zhendong Su (su@cs.ucdavis.edu)
Reported on 2016-04-13 20:26:46 -0700
Last modified on 2016-08-09 14:51:46 -0700
Version trunk
Hardware PC All
CC hans@chromium.org, hfinkel@anl.gov, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
The current clang trunk crashes when compiling the following code on x86_64-
linux-gnu at -O1 and above in both 32-bit and 64-bit modes.

This is a regression from 3.8.x.

$ clang-trunk -v
clang version 3.9.0 (trunk 266174)
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.3
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.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.5
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.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.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-trunk -O0 -c small.c
$ clang-3.8 -O1 -c small.c
$
$ clang-trunk -O1 -c small.c
clang-3.9: /tmp/llvm-builder/llvm-source-
trunk/tools/clang/lib/CodeGen/CGStmt.cpp:1948: void
clang::CodeGen::CodeGenFunction::EmitAsmStmt(const clang::AsmStmt&): Assertion
`OutputTy->isFloatingPointTy() && "Unexpected output type"' failed.
#0 0x0000000001d7b6e5 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1d7b6e5)
#1 0x0000000001d79676 llvm::sys::RunSignalHandlers() (/usr/local/clang-
trunk/bin/clang-3.9+0x1d79676)
#2 0x0000000001d79894 SignalHandler(int) (/usr/local/clang-trunk/bin/clang-
3.9+0x1d79894)
#3 0x00007f167ebc1340 __restore_rt (/lib/x86_64-linux-
gnu/libpthread.so.0+0x10340)
#4 0x00007f167dddfcc9 gsignal /build/eglibc-3GlaMS/eglibc-
2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f167dde30d8 abort /build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f167ddd8b86 __assert_fail_base /build/eglibc-3GlaMS/eglibc-
2.19/assert/assert.c:92:0
#7 0x00007f167ddd8c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x0000000001ef7f26
clang::CodeGen::CodeGenFunction::EmitAsmStmt(clang::AsmStmt const&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1ef7f26)
#9 0x0000000001efdeef
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot) (/usr/local/clang-trunk/bin/clang-
3.9+0x1efdeef)
#10 0x0000000001f212cf
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&,
clang::Stmt const*) (/usr/local/clang-trunk/bin/clang-3.9+0x1f212cf)
#11 0x0000000001f2b75f
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/usr/local/clang-
trunk/bin/clang-3.9+0x1f2b75f)
#12 0x0000000001f4b0b1
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/usr/local/clang-trunk/bin/clang-3.9+0x1f4b0b1)
#13 0x0000000001f58381
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/usr/local/clang-trunk/bin/clang-3.9+0x1f58381)
#14 0x0000000001f58525 clang::CodeGen::CodeGenModule::EmitDeferred()
(/usr/local/clang-trunk/bin/clang-3.9+0x1f58525)
#15 0x0000000001f58694 clang::CodeGen::CodeGenModule::Release()
(/usr/local/clang-trunk/bin/clang-3.9+0x1f58694)
#16 0x00000000024e86c7 (anonymous
namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&)
(/usr/local/clang-trunk/bin/clang-3.9+0x24e86c7)
#17 0x00000000024e3c32
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/usr/local/clang-trunk/bin/clang-3.9+0x24e3c32)
#18 0x000000000282bbed clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x282bbed)
#19 0x00000000024e411e clang::CodeGenAction::ExecuteAction() (/usr/local/clang-
trunk/bin/clang-3.9+0x24e411e)
#20 0x00000000021ca4ae clang::FrontendAction::Execute() (/usr/local/clang-
trunk/bin/clang-3.9+0x21ca4ae)
#21 0x00000000021a2c66
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-3.9+0x21a2c66)
#22 0x0000000002254ea2
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/local/clang-
trunk/bin/clang-3.9+0x2254ea2)
#23 0x0000000000ac1188 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-3.9+0xac1188)
#24 0x0000000000a7cc7d main (/usr/local/clang-trunk/bin/clang-3.9+0xa7cc7d)
#25 0x00007f167ddcaec5 __libc_start_main /build/eglibc-3GlaMS/eglibc-
2.19/csu/libc-start.c:321:0
#26 0x0000000000abd1d4 _start (/usr/local/clang-trunk/bin/clang-3.9+0xabd1d4)
Stack dump:
0.  Program arguments: /usr/local/clang-trunk/bin/clang-3.9 -cc1 -triple x86_64-
unknown-linux-gnu -emit-obj -disable-free -main-file-name small.c -mrelocation-
model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-
aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -momit-leaf-frame-
pointer -dwarf-column-info -debugger-tuning=gdb -coverage-file /data2/small.c -
resource-dir /usr/local/clang-trunk/bin/../lib/clang/3.9.0 -internal-isystem
/usr/local/include -internal-isystem /usr/local/clang-
trunk/bin/../lib/clang/3.9.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-
externc-isystem /usr/include -O1 -fdebug-compilation-dir /data2 -ferror-limit
19 -fmessage-length 147 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-
diagnostics -o small.o -x c small.c
1.  <eof> parser at end of file
2.  Per-file LLVM IR generation
3.  small.c:3:13: Generating code for declaration 'fn1'
clang-3.9: error: unable to execute command: Aborted (core dumped)
clang-3.9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.9.0 (trunk 266174)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/tools/bin
clang-3.9: 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-3.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-3.9: note: diagnostic msg: /tmp/small-9e7721.c
clang-3.9: note: diagnostic msg: /tmp/small-9e7721.sh
clang-3.9: note: diagnostic msg:

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

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

int a[10], b;

inline void fn1 ()
{
  asm ("": "=r" (a):"0" (b));
}

void fn2 ()
{
  fn1 ();
}
Quuxplusone commented 8 years ago

Hmm, this reproduces for me with 3.8 as well. What 3.8 version are you using?

Quuxplusone commented 8 years ago
(In reply to comment #1)
> Hmm, this reproduces for me with 3.8 as well. What 3.8 version are you using?

clang version 3.8.0 (tags/RELEASE_380/final)
Target: x86_64-unknown-linux-gnu
Quuxplusone commented 8 years ago

Very strange. The crash reproduces with my local build of the 3.8 branch, but not with the pre-built clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04 or 3.8.1 packages.

Let's put it on the 3.9 blocker list since it seems to be a regression somehow.

Quuxplusone commented 8 years ago

There's something weird going on here.

I can reproduce the assert with trunk going back to 2013, so I won't treat it as a 3.9 blocker.