[llvm-bugs] [Bug 51612] New: clang crashes at -O2 and -O3 in llvm/CodeGen/SelectionDAGNodes.h:959: llvm::EVT llvm::SDNode::getValueType(unsigned int) const: Assertion `ResNo < NumValues && "Illegal result number!"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 24 19:02:30 PDT 2021


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

            Bug ID: 51612
           Summary: clang crashes at -O2 and -O3 in
                    llvm/CodeGen/SelectionDAGNodes.h:959: llvm::EVT
                    llvm::SDNode::getValueType(unsigned int) const:
                    Assertion `ResNo < NumValues && "Illegal result
                    number!"' failed
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          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 a;
uint64_t b;
int c() {
  uint64_t d = 0;
  uint64_t *e = &d;
  int16_t f = 0;
  uint32_t g = 10;
  uint32_t *i = g;
  for (; b; b++)
    a = ((d ?: b) & *i) >> (*e += 5 || f);
  return 0;
}

$clang -w -m32 -O2 small.c
clang-14:
/home/haoxin/haoxin-data/compilers/llvm-project/llvm/include/llvm/CodeGen/SelectionDAGNodes.h:959:
llvm::EVT llvm::SDNode::getValueType(unsigned int) const: Assertion `ResNo <
NumValues && "Illegal result number!"' 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:
/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14 -cc1 -triple
i386-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 -target-cpu pentium4
-tune-cpu generic -debugger-tuning=gdb
-fcoverage-compilation-dir=/home/haoxin/haoxin-data/dut-research/covsmith-test/20210819/8
-resource-dir
/home/haoxin/haoxin-data/compilers/llvm-project/build/lib/clang/14.0.0
-internal-isystem
/home/haoxin/haoxin-data/compilers/llvm-project/build/lib/clang/14.0.0/include
-internal-isystem /usr/local/include -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O2
-w
-fdebug-compilation-dir=/home/haoxin/haoxin-data/dut-research/covsmith-test/20210819/8
-ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops
-vectorize-slp -faddrsig -o /tmp/small-8d5aa4.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 'X86 DAG->DAG Instruction Selection' on function '@c'
 #0 0x00005577ba629e24 PrintStackTraceSignalHandler(void*)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3b26e24)
 #1 0x00005577ba62753e SignalHandler(int)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3b2453e)
 #2 0x00007faf8d9bc3c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #3 0x00007faf8d45b18b raise
/build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #4 0x00007faf8d43a859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7
 #5 0x00007faf8d43a729 get_sysdep_segment_value
/build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:509:8
 #6 0x00007faf8d43a729 _nl_load_domain
/build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:970:34
 #7 0x00007faf8d44bf36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
 #8 0x00005577bb4e9235
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x49e6235)
 #9 0x00005577bb553be5 (anonymous
namespace)::DAGCombiner::visitADDO(llvm::SDNode*)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4a50be5)
#10 0x00005577bb58c4cb (anonymous namespace)::DAGCombiner::visit(llvm::SDNode*)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4a894cb)
#11 0x00005577bb58ef45 (anonymous
namespace)::DAGCombiner::combine(llvm::SDNode*)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4a8bf45)
#12 0x00005577bb590990 llvm::SelectionDAG::Combine(llvm::CombineLevel,
llvm::AAResults*, llvm::CodeGenOpt::Level)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4a8d990)
#13 0x00005577bb698645 llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(.localalias)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4b95645)
#14 0x00005577bb69c18b
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(.localalias)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4b9918b)
#15 0x00005577bb69e3a1
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4b9b3a1)
#16 0x00005577b90a6e40 (anonymous
namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x25a3e40)
#17 0x00005577b97e5568
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.localalias)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x2ce2568)
#18 0x00005577b9cd7c35 llvm::FPPassManager::runOnFunction(llvm::Function&)
(.localalias)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x31d4c35)
#19 0x00005577b9cd7e79 llvm::FPPassManager::runOnModule(llvm::Module&)
(.localalias)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x31d4e79)
#20 0x00005577b9cd8f62 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(.localalias)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x31d5f62)
#21 0x00005577ba96e94a (anonymous
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3e6b94a)
#22 0x00005577ba97047d clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef,
llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3e6d47d)
#23 0x00005577bb7d3d9f
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4cd0d9f)
#24 0x00005577bc53f3e9 clang::ParseAST(clang::Sema&, bool, bool) (.localalias)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x5a3c3e9)
#25 0x00005577bb7d28e8 clang::CodeGenAction::ExecuteAction() (.localalias)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4ccf8e8)
#26 0x00005577bb067199 clang::FrontendAction::Execute()
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4564199)
#27 0x00005577baffc8ae
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (.localalias)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x44f98ae)
#28 0x00005577bb145fb0
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4642fb0)
#29 0x00005577b7e3c2dd cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x13392dd)
#30 0x00005577b7e38628 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x1335628)
#31 0x00005577b7d6daa9 main
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x126aaa9)
#32 0x00007faf8d43c0b3 __libc_start_main
/build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
#33 0x00005577b7e3819e _start
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x133519e)
clang-14: error: unable to execute command: Aborted (core dumped)
clang-14: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 14.0.0 (https://github.com/llvm/llvm-project
c2574e63ff71c1d3caea48cb6200c2422bd8f33d)
Target: i386-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/haoxin-data/compilers/llvm-project/build/bin
clang-14: note: diagnostic msg:
********************

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

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


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/20210825/565aa9bd/attachment.html>


More information about the llvm-bugs mailing list