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

llvm::SelectionDAGISel -- cannot select ch = PPCISD::STBRX<(store (s64) into %ir.0, !tbaa !49)>

Open ltertan opened this issue 4 years ago • 3 comments

Compile options:

clang --target=ppc64 -mcpu=a2 -O2 example.cpp

example.cpp

typedef long unsigned int UINT64;
typedef unsigned short UINT16;

typedef struct {
    unsigned long num;
    unsigned short val[4];
} Mystruct;

int myFunc (Mystruct *device)
{
    device->num = (UINT64 )( ((UINT64)
    (UINT16)((((device->val[0]) & 0x00ff) << 8) | (((device->val[0]) & 0xff00) >> 8))) |
    ((UINT64)
    (UINT16)((((device->val[1]) & 0x00ff) << 8) | (((device->val[1]) & 0xff00) >> 8)) << 16) |
    ((UINT64)
    (UINT16)((((device->val[2]) & 0x00ff) << 8) | (((device->val[2]) & 0xff00) >> 8)) << 32) |
    ((UINT64)
    (UINT16)((((device->val[3]) & 0x00ff) << 8) | (((device->val[3]) & 0xff00) >> 8)) << 48));

    return (0);
}

Error

Output of power64le clang (trunk) (Compiler #1)
fatal error: error in backend: Cannot select: 0x563593150ae0: ch = PPCISD::STBRX<(store (s64) into %ir.0, !tbaa !49)> 0x5635930f91d8, 0x563593151570, 0x563593150738, ValueType:ch:i64, example.cpp:11:17
  0x563593151570: i64,ch = load<(load (s64) from %ir.2)> 0x5635930f91d8, 0x563593150808, undef:i64, example.cpp:16:94
    0x563593150808: i64 = add nuw 0x563593150738, Constant:i64<8>, example.cpp:12:25
      0x563593150738: i64,ch = CopyFromReg 0x5635930f91d8, Register:i64 %0
        0x5635931506d0: i64 = Register %0
      0x5635931507a0: i64 = Constant<8>
    0x5635931508d8: i64 = undef
  0x563593150738: i64,ch = CopyFromReg 0x5635930f91d8, Register:i64 %0
    0x5635931506d0: i64 = Register %0
In function: _Z6myFuncP8Mystruct

Stack dump

0.	Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o /app/output.s -S -target powerpc64le -fcolor-diagnostics -fno-crash-diagnostics -mcpu=a2 --target=ppc64 -O2 <source>
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '<source>'.
4.	Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on function '@_Z6myFuncP8Mystruct'
 #0 0x000056358c5e060f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x000056358c5de444 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35de444)
 #2 0x000056358c5179d2 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35179d2)
 #3 0x000056358c5d6f9e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35d6f9e)
 #4 0x000056358a1c33f6 (/opt/compiler-explorer/clang-trunk/bin/clang+++0x11c33f6)
 #5 0x000056358c51f1ff llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x351f1ff)
 #6 0x000056358d4b7cf6 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44b7cf6)
 #7 0x000056358d4baca2 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44baca2)
 #8 0x000056358ae6c9e7 (anonymous namespace)::PPCDAGToDAGISel::Select(llvm::SDNode*) PPCISelDAGToDAG.cpp:0:0
 #9 0x000056358d4b6854 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44b6854)
#10 0x000056358d4be1c6 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44be1c6)
#11 0x000056358d4c184b llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44c184b)
#12 0x000056358d4c3a3f llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.889) SelectionDAGISel.cpp:0:0
#13 0x000056358ae72f46 (anonymous namespace)::PPCDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) PPCISelDAGToDAG.cpp:0:0
#14 0x000056358b91b2e8 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x291b2e8)
#15 0x000056358bd8c2a9 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2d8c2a9)
#16 0x000056358bd8c541 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2d8c541)
#17 0x000056358bd8cfe7 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2d8cfe7)
#18 0x000056358c92fce2 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> >) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x392fce2)
#19 0x000056358d5d961f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45d961f)
#20 0x000056358e50bc59 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x550bc59)
#21 0x000056358d5da0bd clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45da0bd)
#22 0x000056358cfbd851 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3fbd851)
#23 0x000056358cf55552 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3f55552)
#24 0x000056358d08a073 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x408a073)
#25 0x000056358a1c4f34 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x11c4f34)
#26 0x000056358a1c0edd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#27 0x000056358cde8b05 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#28 0x000056358c517863 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3517863)
#29 0x000056358cdeabd8 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3deabd8)
#30 0x000056358cdbb1ea clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3dbb1ea)
#31 0x000056358cdbbd2f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3dbbd2f)
#32 0x000056358cdc4785 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3dc4785)
#33 0x000056358a0efc4f main (/opt/compiler-explorer/clang-trunk/bin/clang+++0x10efc4f)
#34 0x00007f19b123d0b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b3)
#35 0x000056358a1c0a5a _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0x11c0a5a)
clang-15: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Compiler returned: 70

Notes

A2 is the only CPU this manifests itself on. Appears to be introduced in LLVM 14, as this is not reproducible on LLVM 13.

ltertan avatar May 04 '22 17:05 ltertan

@llvm/issue-subscribers-backend-powerpc

llvmbot avatar May 05 '22 01:05 llvmbot

Created https://reviews.llvm.org/D125203 for review

orcguru avatar May 09 '22 04:05 orcguru

https://reviews.llvm.org/D125203 landed.

orcguru avatar May 11 '22 06:05 orcguru