[llvm-bugs] [Bug 50480] New: clang crashes at lib/CodeGen/RegAllocFast.cpp:946: void (anonymous namespace)::RegAllocFast::useVirtReg(llvm::MachineInstr &, unsigned int, llvm::Register) Assertion `(!MO.isKill() || LRI->LastUse == &MI) && "Invalid kill flag"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 26 04:22:36 PDT 2021


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

            Bug ID: 50480
           Summary: clang crashes at lib/CodeGen/RegAllocFast.cpp:946:
                    void (anonymous
                    namespace)::RegAllocFast::useVirtReg(llvm::MachineInst
                    r &, unsigned int, llvm::Register) Assertion
                    `(!MO.isKill() || LRI->LastUse == &MI) && "Invalid
                    kill flag"' 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. 

The following small valid C code makes the trunk version of clang crash.

$cat small.c
#include <stdint.h>
int a, c, d;
int64_t b;
void e() {
  if (b = (d -= 4) != (c *= a) % (0 || 3))
    ;
}

$clang -w -m32 small.c
clang-13:
/home/tuhaoxin/compilers/llvm-project/llvm/lib/CodeGen/RegAllocFast.cpp:946:
void (anonymous namespace)::RegAllocFast::useVirtReg(llvm::MachineInstr &,
unsigned int, llvm::Register): Assertion `(!MO.isKill() || LRI->LastUse == &MI)
&& "Invalid kill flag"' 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/tuhaoxin/compilers/llvm-project/build/bin/clang-13 -cc1 -triple
i386-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free
-main-file-name small.c -mrelocation-model static -mframe-pointer=all
-fmath-errno -fno-rounding-math -mconstructor-aliases -target-cpu pentium4
-tune-cpu generic -debugger-tuning=gdb
-fcoverage-compilation-dir=/home/tuhaoxin/dut-research/covsmith-test/20210520/7
-resource-dir /home/tuhaoxin/compilers/llvm-project/build/lib/clang/13.0.0
-c-isystem /usr/local/include/csmith-2.4.0 -cxx-isystem
/usr/local/include/csmith-2.4.0 -internal-isystem
/home/tuhaoxin/compilers/llvm-project/build/lib/clang/13.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 -w
-fdebug-compilation-dir=/home/tuhaoxin/dut-research/covsmith-test/20210520/7
-ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -o
/tmp/small-2ef1c7.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 'Fast Register Allocator' on function '@e'
 #0 0x0000000002aae9c3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x2aae9c3)
 #1 0x0000000002aac70e llvm::sys::RunSignalHandlers()
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x2aac70e)
 #2 0x0000000002aaed4f SignalHandler(int)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x2aaed4f)
 #3 0x00007fe88a7a33c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #4 0x00007fe88a23818b raise
/build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007fe88a217859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00007fe88a217729 get_sysdep_segment_value
/build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:509:8
 #7 0x00007fe88a217729 _nl_load_domain
/build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:970:34
 #8 0x00007fe88a228f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
 #9 0x0000000002173db8 (anonymous
namespace)::RegAllocFast::allocateInstruction(llvm::MachineInstr&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x2173db8)
#10 0x000000000216f9cb (anonymous
namespace)::RegAllocFast::runOnMachineFunction(llvm::MachineFunction&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x216f9cb)
#11 0x0000000001ed2a2e
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x1ed2a2e)
#12 0x00000000022f4f58 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x22f4f58)
#13 0x00000000022fb758 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x22fb758)
#14 0x00000000022f5607 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x22f5607)
#15 0x0000000002d3e2bc (anonymous
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x2d3e2bc)
#16 0x0000000002d3794d 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/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x2d3794d)
#17 0x00000000039f8758
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x39f8758)
#18 0x00000000043b1f03 clang::ParseAST(clang::Sema&, bool, bool)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x43b1f03)
#19 0x0000000003374433 clang::FrontendAction::Execute()
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x3374433)
#20 0x00000000032e4108
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x32e4108)
#21 0x00000000034246e2
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x34246e2)
#22 0x00000000009dd730 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x9dd730)
#23 0x00000000009db5fd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x9db5fd)
#24 0x00000000009db2e4 main
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x9db2e4)
#25 0x00007fe88a2190b3 __libc_start_main
/build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
#26 0x00000000009d829e _start
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x9d829e)
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.git
4b55102aff29f5ce82b38a9e4a819b959e29ecd7)
Target: i386-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/tuhaoxin/compilers/llvm-project/build/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-08a393.c
clang-13: note: diagnostic msg: /tmp/small-08a393.sh
clang-13: note: diagnostic msg: 

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

$clang -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
4b55102aff29f5ce82b38a9e4a819b959e29ecd7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/tuhaoxin/compilers/llvm-project/build/bin
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/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

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/20210526/5ef2d966/attachment.html>


More information about the llvm-bugs mailing list