[llvm-bugs] [Bug 26287] New: clang crashes at -O1 in 32-bit and 64-bit modes. [llvm::Instruction::Instruction(llvm::Type *, unsigned int, llvm::Use *, unsigned int, llvm::Instruction *): Assertion `BB && "Instruction to insert before is not in a basic block!"' failed]

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jan 25 02:46:18 PST 2016


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

            Bug ID: 26287
           Summary: clang crashes at -O1 in 32-bit and 64-bit modes.
                    [llvm::Instruction::Instruction(llvm::Type *, unsigned
                    int, llvm::Use *, unsigned int, llvm::Instruction *):
                    Assertion `BB && "Instruction to insert before is not
                    in a basic block!"' failed]
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: chengniansun at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The following code crashes the trunk at -O1 and above in both 32-bit and 64-bit
modes on x86_64-linux-gnu. 


$: clang-trunk -v
clang version 3.9.0 (trunk 258659)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.2.1
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.2.1
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$: 
$: clang-trunk small.c -O1 -m32 
small.c:16:14: warning: expression result unused [-Wunused-value]
void fn2() { fn1; }
             ^~~
clang: /tmp/llvm/lib/IR/Instruction.cpp:30:
llvm::Instruction::Instruction(llvm::Type *, unsigned int, llvm::Use *,
unsigned int, llvm::Instruction *): Assertion `BB && "Instruction to insert
before is not in a basic block!"' failed.
0  clang           0x00000000030c8788
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  clang           0x00000000030c8ef7
2  libpthread.so.0 0x00007fda1fc96340
3  libc.so.6       0x00007fda1eca0cc9 gsignal + 57
4  libc.so.6       0x00007fda1eca40d8 abort + 328
5  libc.so.6       0x00007fda1ec99b86
6  libc.so.6       0x00007fda1ec99c32
7  clang           0x0000000002fe00f4
llvm::Instruction::Instruction(llvm::Type*, unsigned int, llvm::Use*, unsigned
int, llvm::Instruction*) + 244
8  clang           0x0000000002fe874a
llvm::UnreachableInst::UnreachableInst(llvm::LLVMContext&, llvm::Instruction*)
+ 42
9  clang           0x0000000002ba973e
llvm::changeToUnreachable(llvm::Instruction*, bool) + 414
10 clang           0x00000000029c44d9
11 clang           0x000000000300bd75
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 869
12 clang           0x0000000000a20543
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions
const&, clang::TargetOptions const&, clang::LangOptions const&,
llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::raw_pwrite_stream*)
+ 9603
13 clang           0x0000000000a00728
14 clang           0x0000000000cb81e6 clang::ParseAST(clang::Sema&, bool, bool)
+ 582
15 clang           0x000000000078d805 clang::FrontendAction::Execute() + 69
16 clang           0x0000000000756821
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1153
17 clang           0x000000000073522c
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 3068
18 clang           0x000000000072aeb8 cc1_main(llvm::ArrayRef<char const*>,
char const*, void*) + 1176
19 clang           0x00000000007338df main + 12543
20 libc.so.6       0x00007fda1ec8bec5 __libc_start_main + 245
21 clang           0x000000000072a94d
Stack dump:
0.    Program arguments: /usr/local/clang-trunk/bin/clang -cc1 -triple
i386-unknown-linux-gnu -emit-obj -disable-free -main-file-name small.c
-mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose
-mconstructor-aliases -fuse-init-array -target-cpu pentium4
-target-linker-version 2.24 -momit-leaf-frame-pointer -dwarf-column-info
-debugger-tuning=gdb -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/3.9.0 -c-isystem . -c-isystem
/usr/local/include/csmith -internal-isystem /usr/local/include
-internal-isystem /usr/local/clang-trunk/bin/../lib/clang/3.9.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O1
-fdebug-compilation-dir
/home/cnsun/reduced-compiler-bugs/instrument/20160124-clang-trunk-m64-g-O3-build-091927/delta
-ferror-limit 19 -fmessage-length 128 -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -o
/home/cnsun/ramdisk/tmp/small-9f32e4.o -x c small.c 
1.    <eof> parser at end of file
2.    Per-module optimization passes
3.    Running pass 'Interprocedural Sparse Conditional Constant Propagation' on
module 'small.c'.
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.9.0 (trunk 258659)
Target: i386-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/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: /home/cnsun/ramdisk/tmp/small-13996a.c
clang: note: diagnostic msg: /home/cnsun/ramdisk/tmp/small-13996a.sh
clang: note: diagnostic msg: 

********************
$: 
$: cat small.c
short a, b;
char c;
static int fn1() {
  int d;
lbl_984:
  d |= a;
  if (b)
    goto lbl_984;
  for (;;) {
    if (c)
      goto lbl_984;
    d++;
  }
}

void fn2() { fn1; }
$:

-- 
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/20160125/9aa795e0/attachment.html>


More information about the llvm-bugs mailing list