[llvm-bugs] [Bug 28148] New: clang crashes on valid code at -Os and above in 32-bit mode on x86_64-linux-gnu: Assertion `(Blocks.empty() || LIB[getHeader()] == this) && "Incorrect LI specified for this loop!"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 15 15:04:34 PDT 2016


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

            Bug ID: 28148
           Summary: clang crashes on valid code at -Os and above in 32-bit
                    mode on x86_64-linux-gnu: Assertion `(Blocks.empty()
                    || LIB[getHeader()] == this) && "Incorrect LI
                    specified for this loop!"' 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 code on
x86_64-linux-gnu at -Os and above in the 32-bit mode (but not in the 64-bit
mode). 

This is a regression from 3.8.x. 


$ clang -v
clang version 3.9.0 (trunk 272769)
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.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 -m32 -O1 -w small.c
$ clang -m64 -Os -w small.c
$ clang-3.8 -m32 -Os -w small.c
$
$ clang -m32 -Os -w small.c
clang-3.9:
/tmp/llvm-builder/llvm-source-trunk/include/llvm/Analysis/LoopInfoImpl.h:189:
void llvm::LoopBase<N, M>::addBasicBlockToLoop(BlockT*,
llvm::LoopInfoBase<BlockT, LoopT>&) [with BlockT = llvm::MachineBasicBlock;
LoopT = llvm::MachineLoop]: Assertion `(Blocks.empty() || LIB[getHeader()] ==
this) && "Incorrect LI specified for this loop!"' failed.
#0 0x0000000001d1c865 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1d1c865)
#1 0x0000000001d1a6f6 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-3.9+0x1d1a6f6)
#2 0x0000000001d1a914 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-3.9+0x1d1a914)
#3 0x00007f3e3fa73340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f3e3ec91cc9 gsignal
/build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f3e3ec950d8 abort
/build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f3e3ec8ab86 __assert_fail_base
/build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f3e3ec8ac32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x000000000171060f llvm::LoopBase<llvm::MachineBasicBlock,
llvm::MachineLoop>::addBasicBlockToLoop(llvm::MachineBasicBlock*,
llvm::LoopInfoBase<llvm::MachineBasicBlock, llvm::MachineLoop>&)
(/usr/local/clang-trunk/bin/clang-3.9+0x171060f)
#9 0x000000000182a39a llvm::BranchFolder::SplitMBBAt(llvm::MachineBasicBlock&,
llvm::MachineInstrBundleIterator<llvm::MachineInstr>, llvm::BasicBlock const*)
(/usr/local/clang-trunk/bin/clang-3.9+0x182a39a)
#10 0x000000000182af3a
llvm::BranchFolder::CreateCommonTailOnlyBlock(llvm::MachineBasicBlock*&,
llvm::MachineBasicBlock*, unsigned int, unsigned int&)
(/usr/local/clang-trunk/bin/clang-3.9+0x182af3a)
#11 0x000000000182bf2e
llvm::BranchFolder::TryTailMergeBlocks(llvm::MachineBasicBlock*,
llvm::MachineBasicBlock*) (/usr/local/clang-trunk/bin/clang-3.9+0x182bf2e)
#12 0x000000000182c84f
llvm::BranchFolder::TailMergeBlocks(llvm::MachineFunction&) [clone .part.332]
(/usr/local/clang-trunk/bin/clang-3.9+0x182c84f)
#13 0x000000000182d776
llvm::BranchFolder::OptimizeFunction(llvm::MachineFunction&,
llvm::TargetInstrInfo const*, llvm::TargetRegisterInfo const*,
llvm::MachineModuleInfo*, llvm::MachineLoopInfo*, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x182d776)
#14 0x000000000186a97b (anonymous
namespace)::MachineBlockPlacement::runOnMachineFunction(llvm::MachineFunction&)
[clone .part.208] (/usr/local/clang-trunk/bin/clang-3.9+0x186a97b)
#15 0x00000000016f47a5
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-3.9+0x16f47a5)
#16 0x0000000001983453 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1983453)
#17 0x0000000001983a9b llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1983a9b)
#18 0x0000000001e6f4ba 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+0x1e6f4ba)
#19 0x00000000024847dd
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/usr/local/clang-trunk/bin/clang-3.9+0x24847dd)
#20 0x00000000027e8d4d clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x27e8d4d)
#21 0x0000000002484b3e clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-3.9+0x2484b3e)
#22 0x0000000002196f3e clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-3.9+0x2196f3e)
#23 0x000000000216c9a6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-3.9+0x216c9a6)
#24 0x0000000002224d42
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2224d42)
#25 0x0000000000af0928 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-3.9+0xaf0928)
#26 0x0000000000aa4b0c main (/usr/local/clang-trunk/bin/clang-3.9+0xaa4b0c)
#27 0x00007f3e3ec7cec5 __libc_start_main
/build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#28 0x0000000000aec994 _start (/usr/local/clang-trunk/bin/clang-3.9+0xaec994)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-3.9 -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
-momit-leaf-frame-pointer -dwarf-column-info -debugger-tuning=gdb -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
/include -internal-externc-isystem /usr/include -Os -w -fdebug-compilation-dir
/data2 -ferror-limit 19 -fmessage-length 187 -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp
-o /tmp/small-d1cd74.o -x c small.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'small.c'.
4.      Running pass 'Branch Probability Basic Block Placement' on function
'@fn3'
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 272769)
Target: i386-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/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-16a5fe.c
clang-3.9: note: diagnostic msg: /tmp/small-16a5fe.sh
clang-3.9: note: diagnostic msg:

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


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


int printf (const char *, ...);

char a, d, h;
int b, e, *i, j, v;
static int c = -1;
short f, g;

static void
fn1 ()
{ 
  int k, l, p = d, s = 3;
  char m, r = 3;
  short n;
  int o;
  char q;

L1:
  if (p == 1)
    { 
      p = l;
      q = r = m;
      s = k;
      l = k ^ e;
      m = ~j;
      k = ~(m | f) * (e && 4);
      if (s && q)
        { 
          printf ("%llu\n", (long long) l);
          goto L1;
        }
      if (j)
        goto L1;
      if (s)
        { 
          printf ("%llu\n", (long long) m);
          goto L1;
        }
      printf ("%lld\n", (long long) k);
    }
  l = p;
  d = m = r;
  k = s;
  char t = f;
  int u = (b & c) | t;
  if (u > n)
    { 
      u = o;
      o = c;
      n = o;
      if (u)
        { 
          n = a / h;
          goto L1;
        }
      if (g)
        { 
          printf ("%llu\n", (long long) o);
          goto L1;
        }
    }
  if (r)
    i[o] = 0;
}

void
fn2 ()
{ 
  for (; b;)
    { 
      c = 0;
      return;
    }
  int *w;
  *w = 0;
}

void
fn3 ()
{ 
  if (a)
    fn2 ();
  if (a)
    fn1 ();
}

int
main ()
{ 
  fn3 ();
  return 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/20160615/4089466d/attachment-0001.html>


More information about the llvm-bugs mailing list