google / souper

A superoptimizer for LLVM IR
Apache License 2.0
2.17k stars 171 forks source link

Assertion `!Current->BlockConstraints.count(I->B) && "Basic block has been added into BlockConstraints!"' failed. #301

Open regehr opened 6 years ago

regehr commented 6 years ago

I think this is a new crash, probably @rsas should take a look at it first.

regehr@john-home:~/redis-4.0.2/src$ cat small.c
a;
b() {
  long c;
  if (d())
    c = e();
  a = c;
  if (a && c)
    a = 0;
}
regehr@john-home:~/redis-4.0.2/src$ /home/regehr/souper-regehr/third_party/llvm/Debug/bin/clang-5.0 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O2 -std=c99 -load /home/regehr/souper-regehr/build/libsouperPass.so -mllvm -z3-path=/usr/bin/z3 -mllvm -solver-timeout=15 -mllvm -souper-external-cache -x c small.c -w
clang-5.0: ../lib/Extractor/KLEEBuilder.cpp:900: bool (anonymous namespace)::ExprBuilder::getUBPaths(souper::Inst *, (anonymous namespace)::UBPath *, std::vector<std::unique_ptr<UBPath> > &, (anonymous namespace)::UBPathInstMap &, unsigned int): Assertion `!Current->BlockConstraints.count(I->B) && "Basic block has been added into BlockConstraints!"' failed.
#0 0x000000000218ce09 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/regehr/souper-regehr/third_party/llvm/Debug-build/../lib/Support/Unix/Signals.inc:398:11
#1 0x000000000218cfb9 PrintStackTraceSignalHandler(void*) /home/regehr/souper-regehr/third_party/llvm/Debug-build/../lib/Support/Unix/Signals.inc:462:1
#2 0x000000000218b613 llvm::sys::RunSignalHandlers() /home/regehr/souper-regehr/third_party/llvm/Debug-build/../lib/Support/Signals.cpp:0:5
#3 0x000000000218d314 SignalHandler(int) /home/regehr/souper-regehr/third_party/llvm/Debug-build/../lib/Support/Unix/Signals.inc:252:1
#4 0x00007f70b97a6390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#5 0x00007f70b8309428 gsignal /build/glibc-Cl5G7W/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#6 0x00007f70b830b02a abort /build/glibc-Cl5G7W/glibc-2.23/stdlib/abort.c:91:0
#7 0x00007f70b8301bd7 __assert_fail_base /build/glibc-Cl5G7W/glibc-2.23/assert/assert.c:92:0
#8 0x00007f70b8301c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#9 0x00007f70b7fac8c8 (anonymous namespace)::ExprBuilder::getUBPaths(souper::Inst*, (anonymous namespace)::UBPath*, std::vector<std::unique_ptr<(anonymous namespace)::UBPath, std::default_delete<(anonymous namespace)::UBPath> >, std::allocator<std::unique_ptr<(anonymous namespace)::UBPath, std::default_delete<(anonymous namespace)::UBPath> > > >&, std::unordered_map<souper::Inst*, std::vector<klee::ref<klee::Expr>, std::allocator<klee::ref<klee::Expr> > >, std::hash<souper::Inst*>, std::equal_to<souper::Inst*>, std::allocator<std::pair<souper::Inst* const, std::vector<klee::ref<klee::Expr>, std::allocator<klee::ref<klee::Expr> > > > > >&, unsigned int) /home/regehr/souper-regehr/build/../lib/Extractor/KLEEBuilder.cpp:0:5
#10 0x00007f70b7face94 (anonymous namespace)::ExprBuilder::getUBPaths(souper::Inst*, (anonymous namespace)::UBPath*, std::vector<std::unique_ptr<(anonymous namespace)::UBPath, std::default_delete<(anonymous namespace)::UBPath> >, std::allocator<std::unique_ptr<(anonymous namespace)::UBPath, std::default_delete<(anonymous namespace)::UBPath> > > >&, std::unordered_map<souper::Inst*, std::vector<klee::ref<klee::Expr>, std::allocator<klee::ref<klee::Expr> > >, std::hash<souper::Inst*>, std::equal_to<souper::Inst*>, std::allocator<std::pair<souper::Inst* const, std::vector<klee::ref<klee::Expr>, std::allocator<klee::ref<klee::Expr> > > > > >&, unsigned int) /home/regehr/souper-regehr/build/../lib/Extractor/KLEEBuilder.cpp:944:11
#11 0x00007f70b7face94 (anonymous namespace)::ExprBuilder::getUBPaths(souper::Inst*, (anonymous namespace)::UBPath*, std::vector<std::unique_ptr<(anonymous namespace)::UBPath, std::default_delete<(anonymous namespace)::UBPath> >, std::allocator<std::unique_ptr<(anonymous namespace)::UBPath, std::default_delete<(anonymous namespace)::UBPath> > > >&, std::unordered_map<souper::Inst*, std::vector<klee::ref<klee::Expr>, std::allocator<klee::ref<klee::Expr> > >, std::hash<souper::Inst*>, std::equal_to<souper::Inst*>, std::allocator<std::pair<souper::Inst* const, std::vector<klee::ref<klee::Expr>, std::allocator<klee::ref<klee::Expr> > > > > >&, unsigned int) /home/regehr/souper-regehr/build/../lib/Extractor/KLEEBuilder.cpp:944:11
#12 0x00007f70b7facdac (anonymous namespace)::ExprBuilder::getUBPaths(souper::Inst*, (anonymous namespace)::UBPath*, std::vector<std::unique_ptr<(anonymous namespace)::UBPath, std::default_delete<(anonymous namespace)::UBPath> >, std::allocator<std::unique_ptr<(anonymous namespace)::UBPath, std::default_delete<(anonymous namespace)::UBPath> > > >&, std::unordered_map<souper::Inst*, std::vector<klee::ref<klee::Expr>, std::allocator<klee::ref<klee::Expr> > >, std::hash<souper::Inst*>, std::equal_to<souper::Inst*>, std::allocator<std::pair<souper::Inst* const, std::vector<klee::ref<klee::Expr>, std::allocator<klee::ref<klee::Expr> > > > > >&, unsigned int) /home/regehr/souper-regehr/build/../lib/Extractor/KLEEBuilder.cpp:939:11
#13 0x00007f70b7fa3591 (anonymous namespace)::ExprBuilder::getUBInstCondition() /home/regehr/souper-regehr/build/../lib/Extractor/KLEEBuilder.cpp:820:9
#14 0x00007f70b7fa23f7 souper::GetCandidateExprForReplacement(std::vector<souper::BlockPCMapping, std::allocator<souper::BlockPCMapping> > const&, std::vector<souper::InstMapping, std::allocator<souper::InstMapping> > const&, souper::InstMapping, bool) /home/regehr/souper-regehr/build/../lib/Extractor/KLEEBuilder.cpp:1137:19
#15 0x00007f70b7fa3c85 souper::BuildQuery[abi:cxx11](std::vector<souper::BlockPCMapping, std::allocator<souper::BlockPCMapping> > const&, std::vector<souper::InstMapping, std::allocator<souper::InstMapping> > const&, souper::InstMapping, std::vector<souper::Inst*, std::allocator<souper::Inst*> >*, bool) /home/regehr/souper-regehr/build/../lib/Extractor/KLEEBuilder.cpp:0:40
#16 0x00007f70b7fc1101 (anonymous namespace)::BaseSolver::infer(std::vector<souper::BlockPCMapping, std::allocator<souper::BlockPCMapping> > const&, std::vector<souper::InstMapping, std::allocator<souper::InstMapping> > const&, souper::Inst*, souper::Inst*&, souper::InstContext&) /home/regehr/souper-regehr/build/../lib/Extractor/Solver.cpp:0:29
#17 0x00007f70b7fc3d17 (anonymous namespace)::ExternalCachingSolver::infer(std::vector<souper::BlockPCMapping, std::allocator<souper::BlockPCMapping> > const&, std::vector<souper::InstMapping, std::allocator<souper::InstMapping> > const&, souper::Inst*, souper::Inst*&, souper::InstContext&) /home/regehr/souper-regehr/build/../lib/Extractor/Solver.cpp:358:46
#18 0x00007f70b7fc2dea (anonymous namespace)::MemCachingSolver::infer(std::vector<souper::BlockPCMapping, std::allocator<souper::BlockPCMapping> > const&, std::vector<souper::InstMapping, std::allocator<souper::InstMapping> > const&, souper::Inst*, souper::Inst*&, souper::InstContext&) /home/regehr/souper-regehr/build/../lib/Extractor/Solver.cpp:269:46
#19 0x00007f70b8028aba (anonymous namespace)::SouperPass::runOnFunction(llvm::Function*) /home/regehr/souper-regehr/build/../lib/Pass/Pass.cpp:261:14
#20 0x00007f70b8027d9b (anonymous namespace)::SouperPass::runOnModule(llvm::Module&) /home/regehr/souper-regehr/build/../lib/Pass/Pass.cpp:326:19
#21 0x0000000001a931da (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/regehr/souper-regehr/third_party/llvm/Debug-build/../lib/IR/LegacyPassManager.cpp:1591:27
#22 0x0000000001a92d06 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/regehr/souper-regehr/third_party/llvm/Debug-build/../lib/IR/LegacyPassManager.cpp:1694:16
#23 0x0000000001a936f1 llvm::legacy::PassManager::run(llvm::Module&) /home/regehr/souper-regehr/third_party/llvm/Debug-build/../lib/IR/LegacyPassManager.cpp:1725:3
#24 0x000000000247fe34 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) /home/regehr/souper-regehr/third_party/llvm/Debug-build/../tools/clang/lib/CodeGen/BackendUtil.cpp:785:21
#25 0x000000000247db5f 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/regehr/souper-regehr/third_party/llvm/Debug-build/../tools/clang/lib/CodeGen/BackendUtil.cpp:1134:15
#26 0x000000000315bf4d clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /home/regehr/souper-regehr/third_party/llvm/Debug-build/../tools/clang/lib/CodeGen/CodeGenAction.cpp:261:7
#27 0x0000000004181446 clang::ParseAST(clang::Sema&, bool, bool) /home/regehr/souper-regehr/third_party/llvm/Debug-build/../tools/clang/lib/Parse/ParseAST.cpp:159:13
#28 0x0000000002bae95c clang::ASTFrontendAction::ExecuteAction() /home/regehr/souper-regehr/third_party/llvm/Debug-build/../tools/clang/lib/Frontend/FrontendAction.cpp:1005:1
#29 0x0000000003159821 clang::CodeGenAction::ExecuteAction() /home/regehr/souper-regehr/third_party/llvm/Debug-build/../tools/clang/lib/CodeGen/CodeGenAction.cpp:993:1
#30 0x0000000002bae3d0 clang::FrontendAction::Execute() /home/regehr/souper-regehr/third_party/llvm/Debug-build/../tools/clang/lib/Frontend/FrontendAction.cpp:906:7
#31 0x0000000002b3d13a clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/regehr/souper-regehr/third_party/llvm/Debug-build/../tools/clang/lib/Frontend/CompilerInstance.cpp:981:7
#32 0x0000000002d26e3f clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/regehr/souper-regehr/third_party/llvm/Debug-build/../tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:251:8
#33 0x0000000000d887a9 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/regehr/souper-regehr/third_party/llvm/Debug-build/../tools/clang/tools/driver/cc1_main.cpp:221:11
#34 0x0000000000d7b7d9 ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) /home/regehr/souper-regehr/third_party/llvm/Debug-build/../tools/clang/tools/driver/driver.cpp:306:5
#35 0x0000000000d7a410 main /home/regehr/souper-regehr/third_party/llvm/Debug-build/../tools/clang/tools/driver/driver.cpp:387:5
#36 0x00007f70b82f4830 __libc_start_main /build/glibc-Cl5G7W/glibc-2.23/csu/../csu/libc-start.c:325:0
#37 0x0000000000d793f9 _start (/home/regehr/souper-regehr/third_party/llvm/Debug/bin/clang-5.0+0xd793f9)
Stack dump:
0.  Program arguments: /home/regehr/souper-regehr/third_party/llvm/Debug/bin/clang-5.0 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O2 -std=c99 -load /home/regehr/souper-regehr/build/libsouperPass.so -mllvm -z3-path=/usr/bin/z3 -mllvm -solver-timeout=15 -mllvm -souper-external-cache -x c small.c -w 
1.  <eof> parser at end of file
2.  Per-module optimization passes
3.  Running pass 'Souper super-optimizer pass' on module 'small.c'.
Aborted
regehr@john-home:~/redis-4.0.2/src$ 
chenyang78 commented 6 years ago

@regehr I think this is same issue that you sent out a couple of weeks ago. I know what the issue is. Let me prepare a patch.

regehr commented 6 years ago

Oops, closing the older one.