[llvm-bugs] [Bug 50431] New: clang crashes on valid code at -O1 and above on x86_64-linux-gnu: Assertion `isReg() && "This is not a register operand!"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 21 02:22:17 PDT 2021


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

            Bug ID: 50431
           Summary: clang crashes on valid code at -O1 and above on
                    x86_64-linux-gnu: Assertion `isReg() && "This is not a
                    register operand!"' failed
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: MC
          Assignee: unassignedbugs at nondot.org
          Reporter: zhendong.su at inf.ethz.ch
                CC: llvm-bugs at lists.llvm.org

[522] % clangtk -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
5e327785da36fa3a00767cfea0a47fcb0f0814aa)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/opfuzz/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.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
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
[523] % 
[523] % clangtk -O0 small.c
[524] % 
[524] % clangtk -O1 small.c
clang-13:
/local/suz-local/software/clangbuild/llvm-project/llvm/include/llvm/MC/MCInst.h:70:
unsigned int llvm::MCOperand::getReg() const: Assertion `isReg() && "This is
not a register operand!"' 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:
/local/suz-local/software/local/clang-trunk/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=/local/suz-local/software/emitesting/bugs/20210517-clangtk-m64-O3-build-131816/delta
-resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/13.0.0
-internal-isystem
/local/suz-local/software/local/clang-trunk/lib/clang/13.0.0/include
-internal-isystem /usr/local/include -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../x86_64-linux-gnu/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O1
-fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20210517-clangtk-m64-O3-build-131816/delta
-ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig
-D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-0f9e5d.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 Assembly Printer' on function '@main'
 #0 0x00005600fe8057cc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x374c7cc)
 #1 0x00005600fe803684 llvm::sys::RunSignalHandlers()
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x374a684)
 #2 0x00005600fe8037f3 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f04b299f980 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #4 0x00007f04b1650fb7 raise
/build/glibc-S9d2JN/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f04b1652921 abort /build/glibc-S9d2JN/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f04b164248a __assert_fail_base
/build/glibc-S9d2JN/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f04b1642502 (/lib/x86_64-linux-gnu/libc.so.6+0x30502)
 #8 0x00005600fc283bef
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x11cabef)
 #9 0x00005600fd710411
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x2657411)
#10 0x00005600fd71176d (anonymous
namespace)::X86MCCodeEmitter::encodeInstruction(llvm::MCInst const&,
llvm::raw_ostream&, llvm::SmallVectorImpl<llvm::MCFixup>&,
llvm::MCSubtargetInfo const&) const X86MCCodeEmitter.cpp:0:0
#11 0x00005600fe3e92e5 llvm::MCELFStreamer::emitInstToData(llvm::MCInst const&,
llvm::MCSubtargetInfo const&)
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x33302e5)
#12 0x00005600fe406ecb llvm::MCObjectStreamer::emitInstructionImpl(llvm::MCInst
const&, llvm::MCSubtargetInfo const&)
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x334decb)
#13 0x00005600fe4070fc llvm::MCObjectStreamer::emitInstruction(llvm::MCInst
const&, llvm::MCSubtargetInfo const&)
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x334e0fc)
#14 0x00005600fd42fe33
llvm::X86AsmPrinter::EmitAndCountInstruction(llvm::MCInst&)
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x2376e33)
#15 0x00005600fd4348b6 llvm::X86AsmPrinter::emitInstruction(llvm::MachineInstr
const*) (/local/suz-local/software/local/clang-trunk/bin/clang-13+0x237b8b6)
#16 0x00005600ff3d551f llvm::AsmPrinter::emitFunctionBody()
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x431c51f)
#17 0x00005600fd4256b2
llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction&)
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x236c6b2)
#18 0x00005600fdb88fa6
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x2acffa6)
#19 0x00005600fdfff1c8 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x2f461c8)
#20 0x00005600fdfffcf9 llvm::FPPassManager::runOnModule(llvm::Module&)
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x2f46cf9)
#21 0x00005600fdffea46 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x2f45a46)
#22 0x00005600fead85b5 (anonymous
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#23 0x00005600feadbda3 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> >)
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x3a22da3)
#24 0x00005600ff77375a
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x46ba75a)
#25 0x00005601005d7099 clang::ParseAST(clang::Sema&, bool, bool)
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x551e099)
#26 0x00005600ff7738f8 clang::CodeGenAction::ExecuteAction()
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x46ba8f8)
#27 0x00005600ff0f23f1 clang::FrontendAction::Execute()
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x40393f1)
#28 0x00005600ff08e012
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x3fd5012)
#29 0x00005600ff1bdc0a
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x4104c0a)
#30 0x00005600fc46470c cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/local/suz-local/software/local/clang-trunk/bin/clang-13+0x13ab70c)
#31 0x00005600fc45fa49 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#32 0x00005600fc38c5f7 main
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x12d35f7)
#33 0x00007f04b1633bf7 __libc_start_main
/build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:344:0
#34 0x00005600fc45f5ba _start
(/local/suz-local/software/local/clang-trunk/bin/clang-13+0x13a65ba)
clang-13: error: unable to execute command: Aborted
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
5e327785da36fa3a00767cfea0a47fcb0f0814aa)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/opfuzz/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-02b96c.c
clang-13: note: diagnostic msg: /tmp/small-02b96c.sh
clang-13: note: diagnostic msg: 

********************
[525] % 
[525] % cat small.c
volatile unsigned a;
int main() {
  unsigned b = -1;
  unsigned c = 2L << ((b << 5L) - ~~a);
  c || a;
  return 0;
}

-- 
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/20210521/568366ec/attachment.html>


More information about the llvm-bugs mailing list