[llvm-bugs] [Bug 33765] New: "Scope imbalance!" assert coming from EarlyCSE

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 12 16:21:34 PDT 2017


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

            Bug ID: 33765
           Summary: "Scope imbalance!" assert coming from EarlyCSE
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: babokin at gmail.com
                CC: llvm-bugs at lists.llvm.org

clang trunk (rev307729), x86_64. 

> cat f.cpp
extern short var_7, s;
extern unsigned char var_8, var_11, var_19;
extern long int var_45;

void foo() {
  // Comment next two lines to trigger "Instruction does not dominate all
uses!" error.
  if (var_7)
    var_45 = 0;

  if (~(unsigned char)(var_8 * var_19) - ~(var_8 * var_19))
    s = var_8 * var_19 & var_7;
}

> clang++ f.cpp -c -O2
clang-5.0:
/home/dybaboki/llvm/llvm-trunk-20170711/include/llvm/ADT/ScopedHashTable.h:246:
llvm::ScopedHashTableScope<(anonymous namespace)::SimpleValue, llvm::Value *,
llvm::DenseMapInfo<(anonymous namespace)::SimpleValue>,
llvm::RecyclingAllocator<llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator,
4096, 4096>, llvm::ScopedHashTableVal<(anonymous namespace)::SimpleValue,
llvm::Value *>, 32, 8> >::~ScopedHashTableScope() [K = (anonymous
namespace)::SimpleValue, V = llvm::Value *, KInfo =
llvm::DenseMapInfo<(anonymous namespace)::SimpleValue>, AllocatorTy =
llvm::RecyclingAllocator<llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator,
4096, 4096>, llvm::ScopedHashTableVal<(anonymous namespace)::SimpleValue,
llvm::Value *>, 32, 8>]: Assertion `HT.TopLevelMap[ThisEntry->getKey()] ==
ThisEntry && "Scope imbalance!"' failed.
#0 0x00000000012df0bf llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0+0x12df0bf)
#1 0x00000000012df3c6 SignalHandler(int)
(/home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0+0x12df3c6)
#2 0x00007fdd9903e370 __restore_rt (/lib64/libpthread.so.0+0xf370)
#3 0x00007fdd97c361d7 __GI_raise (/lib64/libc.so.6+0x351d7)
#4 0x00007fdd97c378c8 __GI_abort (/lib64/libc.so.6+0x368c8)
#5 0x00007fdd97c2f146 __assert_fail_base (/lib64/libc.so.6+0x2e146)
#6 0x00007fdd97c2f1f2 (/lib64/libc.so.6+0x2e1f2)
#7 0x000000000110215b (anonymous namespace)::EarlyCSE::run()
(/home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0+0x110215b)
#8 0x0000000001108ca2 (anonymous
namespace)::EarlyCSELegacyCommonPass<true>::runOnFunction(llvm::Function&)
(/home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0+0x1108ca2)
#9 0x0000000000e9bfcf llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0+0xe9bfcf)
#10 0x0000000001c52836 (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
(/home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0+0x1c52836)
#11 0x0000000000e9c716 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0+0xe9c716)
#12 0x000000000144f19b 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> >)
(/home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0+0x144f19b)
#13 0x0000000001aef662
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0+0x1aef662)
#14 0x0000000001f520d6 clang::ParseAST(clang::Sema&, bool, bool)
(/home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0+0x1f520d6)
#15 0x00000000017c8748 clang::FrontendAction::Execute()
(/home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0+0x17c8748)
#16 0x000000000178d6f1
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0+0x178d6f1)
#17 0x000000000184d4c7
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0+0x184d4c7)
#18 0x000000000076cd7f cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0+0x76cd7f)
#19 0x000000000076ab06 main
(/home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0+0x76ab06)
#20 0x00007fdd97c22b35 __libc_start_main (/lib64/libc.so.6+0x21b35)
#21 0x0000000000767e67 _start
(/home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0+0x767e67)
Stack dump:
0.      Program arguments: /home/dybaboki/llvm/bin-trunk-20170711/bin/clang-5.0
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name
f.cpp -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
/home/dybaboki/yarpgen/yarpgen/test_run_july11_creduce/result/clang/compfail/S_2604780597/f.gcno
-resource-dir /home/dybaboki/llvm/bin-trunk-20170711/lib/clang/5.0.0
-internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5
-internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux
-internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/backward
-internal-isystem /usr/local/include -internal-isystem
/home/dybaboki/llvm/bin-trunk-20170711/lib/clang/5.0.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O2
-fdeprecated-macro -fdebug-compilation-dir
/home/dybaboki/yarpgen/yarpgen/test_run_july11_creduce/result/clang/compfail/S_2604780597
-ferror-limit 19 -fmessage-length 272 -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops
-vectorize-slp -o f.o -x c++ f.cpp
1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'CallGraph Pass Manager' on module 'f.cpp'.
4.      Running pass 'Early CSE w/ MemorySSA' on function '@_Z3foov'
clang-5.0: error: unable to execute command: Aborted
clang-5.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 5.0.0 (trunk 307729)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/dybaboki/llvm/bin-trunk-20170711/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:
********************



Note that commenting first two lines in function body causes different crash:
> cat f.cpp
extern short var_7, s;
extern unsigned char var_8, var_11, var_19;
extern long int var_45;

void foo() {
  // Comment next two lines to trigger "Instruction does not dominate all
uses!" error.
//  if (var_7)
//    var_45 = 0;

  if (~(unsigned char)(var_8 * var_19) - ~(var_8 * var_19))
    s = var_8 * var_19 & var_7;
}

> clang++ f.cpp -c -O2
Instruction does not dominate all uses!
  %4 = load i16, i16* @var_7, align 2, !tbaa !5
  %2 = trunc i16 %4 to i8
fatal error: error in backend: Broken function found, compilation aborted!
clang-5.0: error: clang frontend command failed with exit code 70 (use -v to
see invocation)
clang version 5.0.0 (trunk 307729)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/dybaboki/llvm/bin-trunk-20170711/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/f-ed318e.cpp
clang-5.0: note: diagnostic msg: /tmp/f-ed318e.sh
clang-5.0: note: diagnostic msg:

********************

The crash message in the latter case, it possibly may be related to #32795 and
#21220, but assert for broken scopes may be more helpful for fixing the bug.

-- 
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/20170712/26045a91/attachment-0001.html>


More information about the llvm-bugs mailing list