[llvm-bugs] [Bug 50191] New: clang crashes at -O2 in llvm/lib/Analysis/ValueTracking.cpp:2603: llvm::Optional<unsigned int> getInvertibleOperand(const llvm::Operator*, const llvm::Operator*): Assertion `BO1->getOperand(*Idx) == PN1 && BO2->getOperand(*Idx) == PN2' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Sat May 1 05:04:55 PDT 2021


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

            Bug ID: 50191
           Summary: clang crashes at -O2 in
                    llvm/lib/Analysis/ValueTracking.cpp:2603:
                    llvm::Optional<unsigned int>
                    getInvertibleOperand(const llvm::Operator*, const
                    llvm::Operator*): Assertion `BO1->getOperand(*Idx) ==
                    PN1 && BO2->getOperand(*Idx) == PN2' failed
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: llvm-bugs at lists.llvm.org

Hi all.

$cat small.c
#include <stdint.h>
int i_2, c_3;
void fn1() {
  uint8_t uc_7;
  int32_t i_9;
  uint64_t uli_10;
  for (; uc_7; uc_7++)
    for (; c_3; c_3++) {
      uint16_t us_16 = 0;
      for (; us_16 <= 42; us_16++)
        i_9 *= uli_10 | ((i_2 -= i_9) ?: (uc_7 = 3));
    }
}

$clang -w -O2 small.c
clang-13:
/home/haoxin/haoxin-data/dut-research/compilers/llvm-project/llvm/lib/Analysis/ValueTracking.cpp:2603:
llvm::Optional<unsigned int> getInvertibleOperand(const llvm::Operator*, const
llvm::Operator*): Assertion `BO1->getOperand(*Idx) == PN1 &&
BO2->getOperand(*Idx) == PN2' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments:
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations
-disable-free -main-file-name small.c -mrelocation-model static
-mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases
-munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb
-fcoverage-compilation-dir=/home/haoxin/haoxin-data/test -resource-dir
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/lib/clang/13.0.0
-c-isystem /usr/local/include/csmith-2.3.0 -cxx-isystem
/usr/local/include/csmith-2.3.0 -internal-isystem
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/lib/clang/13.0.0/include
-internal-isystem /usr/local/include -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O2
-w -fdebug-compilation-dir=/home/haoxin/haoxin-data/test -ferror-limit 19
-fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp
-faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-8b700f.o -x c small.c
1.      <eof> parser at end of file
2.      Optimizer
 #0 0x000055fbe6cfb37c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x35b537c)
 #1 0x000055fbe6cf9184 llvm::sys::RunSignalHandlers()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x35b3184)
 #2 0x000055fbe6cf92f3 SignalHandler(int)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x35b32f3)
 #3 0x00007ff27a7a7980 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #4 0x00007ff2793cffb7 gsignal
/build/glibc-S9d2JN/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007ff2793d1921 abort /build/glibc-S9d2JN/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007ff2793c148a __assert_fail_base
/build/glibc-S9d2JN/glibc-2.27/assert/assert.c:89:0
 #7 0x00007ff2793c1502 (/lib/x86_64-linux-gnu/libc.so.6+0x30502)
 #8 0x000055fbe5e97f0a getInvertibleOperand(llvm::Operator const*,
llvm::Operator const*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x2751f0a)
 #9 0x000055fbe5eb13a3 isKnownNonEqual(llvm::Value const*, llvm::Value const*,
unsigned int, (anonymous namespace)::Query const&) [clone .part.1207]
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x276b3a3)
#10 0x000055fbe5eb19d2 llvm::isKnownNonEqual(llvm::Value const*, llvm::Value
const*, llvm::DataLayout const&, llvm::AssumptionCache*, llvm::Instruction
const*, llvm::DominatorTree const*, bool)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x276b9d2)
#11 0x000055fbe5d1a8bf SimplifyICmpInst(unsigned int, llvm::Value*,
llvm::Value*, llvm::SimplifyQuery const&, unsigned int)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x25d48bf)
#12 0x000055fbe677c8f5 llvm::InstCombinerImpl::visitICmpInst(llvm::ICmpInst&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x30368f5)
#13 0x000055fbe6700fa5 llvm::InstCombinerImpl::run()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x2fbafa5)
#14 0x000055fbe67042a8 combineInstructionsOverFunction(llvm::Function&,
llvm::InstCombineWorklist&, llvm::AAResults*, llvm::AssumptionCache&,
llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&,
llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*,
llvm::ProfileSummaryInfo*, unsigned int, llvm::LoopInfo*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x2fbe2a8)
#15 0x000055fbe6704de6 llvm::InstCombinePass::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x2fbede6)
#16 0x000055fbe7cca261 llvm::detail::PassModel<llvm::Function,
llvm::InstCombinePass, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x4584261)
#17 0x000055fbe6505165 llvm::PassManager<llvm::Function,
llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x2dbf165)
#18 0x000055fbe4b6e9c1 llvm::detail::PassModel<llvm::Function,
llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>,
llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x14289c1)
#19 0x000055fbe6504c00 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x2dbec00)
#20 0x000055fbe4b6f011 llvm::detail::PassModel<llvm::Module,
llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x1429011)
#21 0x000055fbe6504025 llvm::PassManager<llvm::Module,
llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x2dbe025)
#22 0x000055fbe6fd1781 (anonymous
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x388b781)
#23 0x000055fbe6fd5f1d 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> >)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x388ff1d)
#24 0x000055fbe7c69c86
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x4523c86)
#25 0x000055fbe87dd149 clang::ParseAST(clang::Sema&, bool, bool)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x5097149)
#26 0x000055fbe7c68a48 clang::CodeGenAction::ExecuteAction()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x4522a48)
#27 0x000055fbe75f4079 clang::FrontendAction::Execute()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x3eae079)
#28 0x000055fbe7591f01
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x3e4bf01)
#29 0x000055fbe76bb900
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x3f75900)
#30 0x000055fbe48d833d cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x119233d)
#31 0x000055fbe48d4877 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x118e877)
#32 0x000055fbe48029aa main
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x10bc9aa)
#33 0x00007ff2793b2bf7 __libc_start_main
/build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:344:0
#34 0x000055fbe48d431a _start
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin/clang-13+0x118e31a)
clang-13: error: unable to execute command: Aborted (core dumped)
clang-13: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 13.0.0 (https://github.com/llvm/llvm-project
e5984a3680bef22d422beaafa73bf131d7197973)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/home/haoxin/haoxin-data/dut-research/compilers/llvm-project/build-20210427/bin
clang-13: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-13: note: diagnostic msg: /tmp/small-ee730e.c
clang-13: note: diagnostic msg: /tmp/small-ee730e.sh
clang-13: note: diagnostic msg: 

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

By the way, this issue only crashes on the current trunk of clang, and released
versions are performed well in this case.

Thanks,
Haoxin

-- 
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/20210501/c637b0e4/attachment-0001.html>


More information about the llvm-bugs mailing list