[llvm-bugs] [Bug 32686] New: clang crashes on valid code at -O1 and above on x86_64-linux-gnu running pass 'Combine redundant instructions': Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Apr 17 12:12:41 PDT 2017


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

            Bug ID: 32686
           Summary: clang crashes on valid code at -O1 and above on
                    x86_64-linux-gnu running pass 'Combine redundant
                    instructions': Assertion `isa<X>(Val) && "cast<Ty>()
                    argument of incompatible type!"' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: llvm-bugs at lists.llvm.org

It looks like a very recent regression. 


$ clang -v
clang version 5.0.0 (trunk 300426)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/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.4
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5
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.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.2.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 -O0 -c -w small.c
$
$ clang -O1 -c -w small.c
clang-5.0:
/tmp/llvm-builder/llvm-source-trunk/include/llvm/Support/Casting.h:254:
typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X =
llvm::Instruction; Y = llvm::Value; typename llvm::cast_retty<X, Y*>::ret_type
= llvm::Instruction*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of
incompatible type!"' failed.
#0 0x0000000002171dca llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-5.0+0x2171dca)
#1 0x000000000216feee llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-5.0+0x216feee)
#2 0x0000000002170050 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-5.0+0x2170050)
#3 0x00007fe21344c330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#4 0x00007fe212235c37 gsignal
/build/eglibc-MjiXCM/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007fe212239028 abort
/build/eglibc-MjiXCM/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007fe21222ebf6 __assert_fail_base
/build/eglibc-MjiXCM/eglibc-2.19/assert/assert.c:92:0
#7 0x00007fe21222eca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#8 0x00000000008af174 llvm::PointerIntPairInfo<llvm::Instruction*, 1u,
llvm::PointerLikeTypeTraits<llvm::Instruction*> >::updateInt(long, long) [clone
.part.246] (/usr/local/clang-trunk/bin/clang-5.0+0x8af174)
#9 0x0000000001839f91 (/usr/local/clang-trunk/bin/clang-5.0+0x1839f91)
#10 0x0000000001e271a3 llvm::InstCombiner::visitOr(llvm::BinaryOperator&)
(/usr/local/clang-trunk/bin/clang-5.0+0x1e271a3)
#11 0x0000000001e0f417 llvm::InstCombiner::run()
(/usr/local/clang-trunk/bin/clang-5.0+0x1e0f417)
#12 0x0000000001e1034b combineInstructionsOverFunction(llvm::Function&,
llvm::InstCombineWorklist&, llvm::AAResults*, llvm::AssumptionCache&,
llvm::TargetLibraryInfo&, llvm::DominatorTree&, bool, llvm::LoopInfo*)
(/usr/local/clang-trunk/bin/clang-5.0+0x1e1034b)
#13 0x0000000001e107e8
llvm::InstructionCombiningPass::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-5.0+0x1e107e8)
#14 0x0000000001d15da3 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-5.0+0x1d15da3)
#15 0x0000000001d15e4c llvm::FPPassManager::runOnModule(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-5.0+0x1d15e4c)
#16 0x0000000001d1668a llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-5.0+0x1d1668a)
#17 0x000000000230747d (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/usr/local/clang-trunk/bin/clang-5.0+0x230747d)
#18 0x00000000023088b1 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> >)
(/usr/local/clang-trunk/bin/clang-5.0+0x23088b1)
#19 0x00000000029da557
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/usr/local/clang-trunk/bin/clang-5.0+0x29da557)
#20 0x0000000002dd96cc clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-5.0+0x2dd96cc)
#21 0x00000000029d990a clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-5.0+0x29d990a)
#22 0x0000000002697e3e clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-5.0+0x2697e3e)
#23 0x000000000266e53e
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-5.0+0x266e53e)
#24 0x000000000272c072
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-5.0+0x272c072)
#25 0x0000000000c733a8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-5.0+0xc733a8)
#26 0x0000000000c133e2 main (/usr/local/clang-trunk/bin/clang-5.0+0xc133e2)
#27 0x00007fe212220f45 __libc_start_main
/build/eglibc-MjiXCM/eglibc-2.19/csu/libc-start.c:321:0
#28 0x0000000000c6eff9 _start (/usr/local/clang-trunk/bin/clang-5.0+0xc6eff9)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-5.0 -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-notes-file /data2/small.gcno -resource-dir
/usr/local/clang-trunk/lib/clang/5.0.0 -internal-isystem /usr/local/include
-internal-isystem /usr/local/clang-trunk/lib/clang/5.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O1
-w -fdebug-compilation-dir /data2 -ferror-limit 19 -fmessage-length 160
-fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o small.o -x
c small.c
1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'Function Pass Manager' on module 'small.c'.
4.      Running pass 'Combine redundant instructions' on function '@fn1'
clang-5.0: error: unable to execute command: Aborted (core dumped)
clang-5.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 5.0.0 (trunk 300426)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
clang-5.0: 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-5.0: note: diagnostic msg:
********************

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

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


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


char a;
int b;

void fn1 ()
{ 
  char *c = &a;
  b = (2 ^ (c != &b)) | !a;
}

-- 
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/20170417/099b765a/attachment.html>


More information about the llvm-bugs mailing list