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

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 20 23:15:12 PDT 2016


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

            Bug ID: 28636
           Summary: clang crashes on valid code at -O1 and above on
                    x86_64-linux-gnu (in 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: 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 test case 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 -v
clang version 4.0.0 (trunk 276092)
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.3
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.3
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.1.1
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 small.c
$ clang-3.8 -O1 -c small.c
$
$ clang -O1 -c small.c
clang-4.0:
/tmp/llvm-builder/llvm-source-trunk/include/llvm/Support/Casting.h:223:
typename std::enable_if<(! llvm::is_simple_type<Y>::value), typename
llvm::cast_retty<X, const Y>::ret_type>::type llvm::cast(const Y&) [with X =
llvm::PHINode; Y = llvm::ilist_iterator<llvm::Instruction>; typename
std::enable_if<(! llvm::is_simple_type<Y>::value), typename llvm::cast_retty<X,
const Y>::ret_type>::type = llvm::PHINode*]: Assertion `isa<X>(Val) &&
"cast<Ty>() argument of incompatible type!"' failed.
#0 0x0000000001d8fa95 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1d8fa95)
#1 0x0000000001d8db4e llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-4.0+0x1d8db4e)
#2 0x0000000001d8dcb0 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-4.0+0x1d8dcb0)
#3 0x00007f8a7b833340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f8a7a624cc9 gsignal
/build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f8a7a6280d8 abort
/build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f8a7a61db86 __assert_fail_base
/build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f8a7a61dc32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x0000000001af68c0 llvm::InstCombiner::visitPHINode(llvm::PHINode&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1af68c0)
#9 0x0000000001aa36a7 llvm::InstCombiner::run()
(/usr/local/clang-trunk/bin/clang-4.0+0x1aa36a7)
#10 0x0000000001aa43b0 combineInstructionsOverFunction(llvm::Function&,
llvm::InstCombineWorklist&, llvm::AAResults*, llvm::AssumptionCache&,
llvm::TargetLibraryInfo&, llvm::DominatorTree&, bool, llvm::LoopInfo*)
(/usr/local/clang-trunk/bin/clang-4.0+0x1aa43b0)
#11 0x0000000001aa4758
llvm::InstructionCombiningPass::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1aa4758)
#12 0x00000000019e8403 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-4.0+0x19e8403)
#13 0x00000000019e8a0b llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-4.0+0x19e8a0b)
#14 0x0000000001efc44a clang::EmitBackendOutput(clang::DiagnosticsEngine&,
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-4.0+0x1efc44a)
#15 0x000000000252517f
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/usr/local/clang-trunk/bin/clang-4.0+0x252517f)
#16 0x000000000289369d clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x289369d)
#17 0x00000000025254fe clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-4.0+0x25254fe)
#18 0x00000000022300de clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-4.0+0x22300de)
#19 0x00000000022058d6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-4.0+0x22058d6)
#20 0x00000000022be422
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-4.0+0x22be422)
#21 0x0000000000b18c38 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-4.0+0xb18c38)
#22 0x0000000000ac7637 main (/usr/local/clang-trunk/bin/clang-4.0+0xac7637)
#23 0x00007f8a7a60fec5 __libc_start_main
/build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#24 0x0000000000b14c64 _start (/usr/local/clang-trunk/bin/clang-4.0+0xb14c64)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-4.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-file /data2/small.c -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/4.0.0 -internal-isystem
/usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/4.0.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 224 -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-4.0: error: unable to execute command: Aborted (core dumped)
clang-4.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 4.0.0 (trunk 276092)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
clang-4.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-4.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-4.0: note: diagnostic msg: /tmp/small-70026e.c
clang-4.0: note: diagnostic msg: /tmp/small-70026e.sh
clang-4.0: note: diagnostic msg:

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


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


struct S
{ 
  int f0;
  long f1;
  int f2;
};

int a;

struct S fn1 ()
{ 
  struct S b = { 0, 0, 0 };
  for (; a;)
    { 
      struct S c;
      for (; 1;)
        { 
          a = b.f0;
          for (; a;)
            c = b;
          if (a)
            { 
              int d;
              return c;
            }
          return c;
        }
    }
  return b;
}

-- 
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/20160721/770df062/attachment.html>


More information about the llvm-bugs mailing list