llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

llc crashes when given invalid command line arguments

Open llvmbot opened this issue 14 years ago • 1 comments

Bugzilla Link 9329
Version trunk
OS All
Reporter LLVM Bugzilla Contributor

Extended Description

I accidentally tried to add a CPU attribute as part of the -mcpu argument rather than using -mattr, and with the attached trivial program, got the following crash:

% llc -mcpu=core2+sse41 -march=x86-64 bugpoint-reduced-simplified.bc
'core2+sse41' is not a recognized processor for this target (ignoring processor)
Assertion failed: (TLI.isTypeLegal(Op.getValueType()) && "Intrinsic uses a non-legal type?"), function visitTargetIntrinsic, file SelectionDAGBuilder.cpp, line 3149.
0  llc               0x0000000100b411b2 llvm::PrettyStackTraceString::~PrettyStackTraceString() + 11298
1  llc               0x0000000100b42003 llvm::PrettyStackTraceString::~PrettyStackTraceString() + 14963
2  libSystem.B.dylib 0x00007fff8385567a _sigtramp + 26
3  libSystem.B.dylib 0x0000000101075000 _sigtramp + 2105670048
4  llc               0x0000000100021a32 std::vector<llvm::PassRegistrationListener*, std::allocator<llvm::PassRegistrationListener*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<llvm::PassRegistrationListener**, std::vector<llvm::PassRegistrationListener*, std::allocator<llvm::PassRegistrationListener*> > >, llvm::PassRegistrationListener* const&) + 3394
5  llc               0x00000001005f99af llvm::APInt::getHighBitsSet(unsigned int, unsigned int) + 179023
6  llc               0x00000001005fa510 llvm::APInt::getHighBitsSet(unsigned int, unsigned int) + 181936
7  llc               0x0000000100602e81 llvm::APInt::getHighBitsSet(unsigned int, unsigned int) + 217121
8  llc               0x00000001005e317d llvm::APInt::getHighBitsSet(unsigned int, unsigned int) + 86813
9  llc               0x0000000100618703 llvm::APInt::getHighBitsSet(unsigned int, unsigned int) + 305315
10 llc               0x000000010062cb38 llvm::TargetLowering::getNumRegisters(llvm::LLVMContext&, llvm::EVT) const + 58696
11 llc               0x000000010062d231 llvm::TargetLowering::getNumRegisters(llvm::LLVMContext&, llvm::EVT) const + 60481
12 llc               0x000000010062de5a llvm::TargetLowering::getNumRegisters(llvm::LLVMContext&, llvm::EVT) const + 63594
13 llc               0x000000010073e343 llvm::MachineFunctionAnalysis::getPassName() const + 627
14 llc               0x0000000100a750b0 llvm::BasicBlockPass::~BasicBlockPass() + 32240
15 llc               0x0000000100a751cb llvm::BasicBlockPass::~BasicBlockPass() + 32523
16 llc               0x0000000100a76d4f llvm::BasicBlockPass::~BasicBlockPass() + 39567
17 llc               0x0000000100a77043 llvm::BasicBlockPass::~BasicBlockPass() + 40323
18 llc               0x0000000100a7711d llvm::BasicBlockPass::~BasicBlockPass() + 40541
19 llc               0x00000001000240ff std::vector<llvm::PassRegistrationListener*, std::allocator<llvm::PassRegistrationListener*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<llvm::PassRegistrationListener**, std::vector<llvm::PassRegistrationListener*, std::allocator<llvm::PassRegistrationListener*> > >, llvm::PassRegistrationListener* const&) + 13327
20 llc               0x0000000100022964 std::vector<llvm::PassRegistrationListener*, std::allocator<llvm::PassRegistrationListener*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<llvm::PassRegistrationListener**, std::vector<llvm::PassRegistrationListener*, std::allocator<llvm::PassRegistrationListener*> > >, llvm::PassRegistrationListener* const&) + 7284
Stack dump:
0.	Program arguments: llc -mcpu=core2+sse41 -march=x86-64 bugpoint-reduced-simplified.bc 
1.	Running pass 'Function Pass Manager' on module 'bugpoint-reduced-simplified.bc'.
2.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@simple'
[1]    74409 illegal hardware instruction  llc -mcpu=core2+sse41 -march=x86-64 bugpoint-reduced-simplified.bc

llvmbot avatar Feb 26 '11 03:02 llvmbot

Confirmed

$ llc -mcpu=core2+sse41 -march=x86-64 s_p_i.ll
'core2+sse41' is not a recognized processor for this target (ignoring processor)
'core2+sse41' is not a recognized processor for this target (ignoring processor)
'core2+sse41' is not a recognized processor for this target (ignoring processor)
'core2+sse41' is not a recognized processor for this target (ignoring processor)
'core2+sse41' is not a recognized processor for this target (ignoring processor)
'core2+sse41' is not a recognized processor for this target (ignoring processor)
LLVM ERROR: 64-bit code requested on a subtarget that doesn't support it!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: llc -mcpu=core2+sse41 -march=x86-64 s_p_i.ll
1.      Running pass 'Function Pass Manager' on module 's_p_i.ll'.
2.      Running pass 'Expand large div/rem' on function '@setup_per_cpu_areas'
 #0 0x00007fef5269c736 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xc4c736)
 #1 0x00007fef5269a970 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xc4a970)
 #2 0x00007fef5269cdbb (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xc4cdbb)
 #3 0x00007fef5157bf90 (/lib/x86_64-linux-gnu/libc.so.6+0x3bf90)
 #4 0x00007fef515caccc (/lib/x86_64-linux-gnu/libc.so.6+0x8accc)
 #5 0x00007fef5157bef2 raise (/lib/x86_64-linux-gnu/libc.so.6+0x3bef2)
 #6 0x00007fef51566472 abort (/lib/x86_64-linux-gnu/libc.so.6+0x26472)
 #7 0x00007fef525fc245 llvm::report_fatal_error(llvm::Twine const&, bool) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xbac245)
 #8 0x00007fef525fc086 (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xbac086)
 #9 0x00007fef552a32be (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x38532be)
#10 0x00007fef552a3571 (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x3853571)
#11 0x00007fef552a4a67 (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x3854a67)
#12 0x00007fef52938a0e (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xee8a0e)
#13 0x00007fef527d59df llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xd859df)
#14 0x00007fef527db683 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xd8b683)
#15 0x00007fef527d60b5 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xd860b5)
#16 0x00007fef590012ce main (/usr/lib/llvm-17/bin/llc+0x112ce)
#17 0x00007fef5156718a (/lib/x86_64-linux-gnu/libc.so.6+0x2718a)
#18 0x00007fef51567245 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x27245)
#19 0x00007fef58ffc201 _start (/usr/lib/llvm-17/bin/llc+0xc201)
[1]    2952 IOT instruction (core dumped)  llc -mcpu=core2+sse41 -march=x86-64 s_p_i.ll

$ llc --version
Debian LLVM version 17.0.0
  Optimized build.
  Default target: x86_64-pc-linux-gnu
  Host CPU: alderlake

$ apt show llvm
Package: llvm
Version: 1:17.0-58~exp1~20230129224010.18

$ cat s_p_i.ll
; ModuleID = 's_p.ll'
source_filename = "s_p.i"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define dso_local void @setup_per_cpu_areas(i8* %arg) {
entry:
  %s3 = bitcast i8* %arg to [65536 x i8]*
  store [65536 x i8] zeroinitializer, [65536 x i8]* %s3
  ret void
}

Endilll avatar May 22 '23 05:05 Endilll

The diagnostic is garbage (and absolutely should not print a stack trace, report_fatal_error's default is broken), but this does hit a proper error. The original assertion is gone

arsenm avatar Aug 09 '23 00:08 arsenm

@llvm/issue-subscribers-backend-x86

llvmbot avatar Aug 09 '23 00:08 llvmbot