[llvm-bugs] [Bug 27969] New: clang crashes on valid code at -O2 and -O3 on x86_64-linux-gnu: Assertion `New->getType() == getType() && "replaceAllUses of value with new value of different type!"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 1 11:28:40 PDT 2016


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

            Bug ID: 27969
           Summary: clang crashes on valid code at -O2 and -O3 on
                    x86_64-linux-gnu: Assertion `New->getType() ==
                    getType() && "replaceAllUses of value with new value
                    of different 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 -O2 and -O3 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 271236)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
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.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 -Os -c small.c
$ clang-3.8 -O2 -c small.c
$
$ clang-trunk -O2 -c small.c
clang-3.9: /tmp/llvm-builder/llvm-source-trunk/lib/IR/Value.cpp:375: void
llvm::Value::replaceAllUsesWith(llvm::Value*): Assertion `New->getType() ==
getType() && "replaceAllUses of value with new value of different type!"'
failed.
#0 0x0000000001dfd855 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1dfd855)
#1 0x0000000001dfb7e6 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-3.9+0x1dfb7e6)
#2 0x0000000001dfba04 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-3.9+0x1dfba04)
#3 0x00007fdfaddce340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007fdfacff0cc9 gsignal
/build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007fdfacff40d8 abort
/build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007fdfacfe9b86 __assert_fail_base
/build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007fdfacfe9c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x0000000001a9d215 (/usr/local/clang-trunk/bin/clang-3.9+0x1a9d215)
#9 0x0000000001b55ee1 transformToIndexedCompare(llvm::GEPOperator*,
llvm::Value*, llvm::CmpInst::Predicate, llvm::DataLayout const&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1b55ee1)
#10 0x0000000001b56630 llvm::InstCombiner::FoldGEPICmp(llvm::GEPOperator*,
llvm::Value*, llvm::CmpInst::Predicate, llvm::Instruction&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1b56630)
#11 0x0000000001b583ae llvm::InstCombiner::visitICmpInst(llvm::ICmpInst&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1b583ae)
#12 0x0000000001b1d3c7 llvm::InstCombiner::run()
(/usr/local/clang-trunk/bin/clang-3.9+0x1b1d3c7)
#13 0x0000000001b1e12b combineInstructionsOverFunction(llvm::Function&,
llvm::InstCombineWorklist&, llvm::AAResults*, llvm::AssumptionCache&,
llvm::TargetLibraryInfo&, llvm::DominatorTree&, bool, llvm::LoopInfo*)
(/usr/local/clang-trunk/bin/clang-3.9+0x1b1e12b)
#14 0x0000000001b1e524
llvm::InstructionCombiningPass::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1b1e524)
#15 0x0000000001a631a3 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1a631a3)
#16 0x00000000026a5ca7 (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-3.9+0x26a5ca7)
#17 0x0000000001a638e8 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1a638e8)
#18 0x0000000001f4c9e8 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction,
llvm::raw_pwrite_stream*) (/usr/local/clang-trunk/bin/clang-3.9+0x1f4c9e8)
#19 0x000000000259389d
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/usr/local/clang-trunk/bin/clang-3.9+0x259389d)
#20 0x00000000028f26cd clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x28f26cd)
#21 0x0000000002593bfe clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-3.9+0x2593bfe)
#22 0x0000000002271b4e clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-3.9+0x2271b4e)
#23 0x0000000002247a96
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2247a96)
#24 0x00000000022fea62
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-3.9+0x22fea62)
#25 0x0000000000ae2f58 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-3.9+0xae2f58)
#26 0x0000000000a9c8ae main (/usr/local/clang-trunk/bin/clang-3.9+0xa9c8ae)
#27 0x00007fdfacfdbec5 __libc_start_main
/build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#28 0x0000000000adefc4 _start (/usr/local/clang-trunk/bin/clang-3.9+0xadefc4)
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 -O2 -fdebug-compilation-dir /data2
-ferror-limit 19 -fmessage-length 145 -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp
-o small.o -x c small.c
1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'CallGraph Pass Manager' on module 'small.c'.
4.      Running pass 'Combine redundant instructions' on function '@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 271236)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/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-a0dfdf.c
clang-3.9: note: diagnostic msg: /tmp/small-a0dfdf.sh
clang-3.9: note: diagnostic msg:

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


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


int a, **b, d, e, g;
char c = 1;

void
fn1 ()
{ 
  int *h[1] = { &a }, ***i = &b, **j = &h[0], **k = b = j;
  for (; d;)
    if (e && *i)
      { 
        for (c = 0; c < 2; c++)
          { 
            for (a = 1; a;)
              **b = b != j;
            *k = &g;
          }
        *j = *b;
      }
  ***i = i != 0;
}

-- 
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/20160601/04857ede/attachment-0001.html>


More information about the llvm-bugs mailing list