Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RISC-V Assertion failure in SelectionDagBuilder.cpp when compiling CheriBSD-compiler-rt with 128bit intrinsics: `(PartVT.isInteger() || PartVT == MVT::x86mmx) && ValueVT.isInteger() && "Unknown mismatch!"' #743

Open
romameie opened this issue Jun 26, 2024 · 2 comments

Comments

@romameie
Copy link

romameie commented Jun 26, 2024

Using commit 578ea4f (latest on main at time of writing)
When compiling subrepo-cheri-compiler-rt/lib/builtins/fixdfti.c from https://github.com/CTSRD-CHERI/cheribsd in a custom context for RISC-V purecap target -target riscv64-none-elf -march=rv64imafdcxcheri -mabi=l64pc128d -mxcheri-norvc -mno-relax.

The exact same build step succeeds with the Morello LLVM fork's baremetal release.

clang: /tools_temp/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:534: void getCopyToParts(llvm::SelectionDAG &, const llvm::SDLoc &, llvm::SDValue, llvm::SDValue *, unsigned int, llvm::MVT, const llvm::Value *, OptionalCallingConv::ID, ISD::NodeType): Assertion `(PartVT.isInteger() || PartVT == MVT::x86mmx) && ValueVT.isInteger() && "Unknown mismatch!"' failed.

Processed source: fixdfti-e74d5d.c.txt
Run script: fixdfti-e74d5d.sh.txt

Full trace:

clang: /tools_temp/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:534: void getCopyToParts(llvm::SelectionDAG &, const llvm::SDLoc &, llvm::SDValue, llvm::SDValue *, unsigned int, llvm::MVT, const llvm::Value *, Optional<CallingConv::ID>, ISD::NodeType): Assertion `(PartVT.isInteger() || PartVT == MVT::x86mmx) && ValueVT.isInteger() && "Unknown mismatch!"' failed.
PLEASE submit a bug report to https://github.com/CTSRD-CHERI/llvm-project/issues and include the crash backtrace, preprocessed source, and associated run script.
If you built clang from source, please provide a reduced test case by running:
        $LLVM_BUILD_DIR/bin/creduce_crash_testcase.py <reproducer>.sh
Stack dump:
0.      Program arguments: clang -falign-functions=16 -falign-loops=16 -mstack-alignment=16 -nostdinc -nostdlib -nodefaultlibs -ffreestanding -Wcheri -fno-delete-null-pointer-checks -ftrapv -c -MT riscv64/compiler_rt/common/arch/cheri/freebsd/lib/freebsd/contrib/subrepo-cheri-compiler-rt/lib/builtins/fixdfti.c.o -MD -MP -MF riscv64/compiler_rt/common/arch/cheri/freebsd/lib/freebsd/contrib/subrepo-cheri-compiler-rt/lib/builtins/fixdfti.c.o.d -g -O0 -fPIC -o riscv64/compiler_rt/common/arch/cheri/freebsd/lib/freebsd/contrib/subrepo-cheri-compiler-rt/lib/builtins/fixdfti.c.o /src/lib/freebsd/contrib/subrepo-cheri-compiler-rt/lib/builtins/fixdfti.c -Wno-missing-prototypes -Wno-missing-declarations -Wno-strict-prototypes -Wno-old-style-definition -Wno-redundant-decls -D__FreeBSD__ -D__ELF__ -DRISCV_XLEN=64 -target riscv64-none-elf -march=rv64imafdcxcheri -mabi=l64pc128d -mxcheri-norvc -mno-relax -I /src/include/common -I /src/compat/include/freebsd/include -I /src/compat/include/freebsd/sys -I /src/compat/include/freebsd/sys/sys -I /src/lib/freebsd/libc/include -I /src/include/arch/riscv64 -I /src/compat/freebsd/sys -I /src/compat/include/freebsd/sys/riscv/ -I /src/compat/include/freebsd/sys/riscv/machine/
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '/src/lib/freebsd/contrib/subrepo-cheri-compiler-rt/lib/builtins/fixdfti.c'.
4.      Running pass 'RISCV DAG->DAG Pattern Instruction Selection' on function '@__fixint'
 #0 0x00007f4d927d4643 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local/bin/../lib/libLLVMSupport.so.15git+0x1ee643)
 #1 0x00007f4d927d22be llvm::sys::RunSignalHandlers() (/usr/local/bin/../lib/libLLVMSupport.so.15git+0x1ec2be)
 #2 0x00007f4d926d6303 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
 #3 0x00007f4d926d64ee CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x00007f4d920c5520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #5 0x00007f4d921199fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #6 0x00007f4d920c5476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #7 0x00007f4d920ab7f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #8 0x00007f4d920ab71b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #9 0x00007f4d920bce96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#10 0x00007f4d91b75869 getCopyToParts(llvm::SelectionDAG&, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue*, unsigned int, llvm::MVT, llvm::Value const*, llvm::Optional<unsigned int>, llvm::ISD::NodeType) SelectionDAGBuilder.cpp:0:0
#11 0x00007f4d91b96174 llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&) const (/usr/local/bin/../lib/../lib/libLLVMSelectionDAG.so.15git+0x210174)
#12 0x00007f4d91aeff1e llvm::DAGTypeLegalizer::ExpandIntRes_XMULO(llvm::SDNode*, llvm::SDValue&, llvm::SDValue&) (/usr/local/bin/../lib/../lib/libLLVMSelectionDAG.so.15git+0x169f1e)
#13 0x00007f4d91ae350e llvm::DAGTypeLegalizer::ExpandIntegerResult(llvm::SDNode*, unsigned int) (/usr/local/bin/../lib/../lib/libLLVMSelectionDAG.so.15git+0x15d50e)
#14 0x00007f4d91afddb7 llvm::DAGTypeLegalizer::run() (/usr/local/bin/../lib/../lib/libLLVMSelectionDAG.so.15git+0x177db7)
#15 0x00007f4d91b02df0 llvm::SelectionDAG::LegalizeTypes() (/usr/local/bin/../lib/../lib/libLLVMSelectionDAG.so.15git+0x17cdf0)
#16 0x00007f4d91c4ad40 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/usr/local/bin/../lib/../lib/libLLVMSelectionDAG.so.15git+0x2c4d40)
#17 0x00007f4d91c4948e llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/usr/local/bin/../lib/../lib/libLLVMSelectionDAG.so.15git+0x2c348e)
#18 0x00007f4d91c455ce llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/usr/local/bin/../lib/../lib/libLLVMSelectionDAG.so.15git+0x2bf5ce)
#19 0x00007f4d95cc9b09 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/usr/local/bin/../lib/libLLVMCodeGen.so.15git+0x31ab09)
#20 0x00007f4d934f9435 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/local/bin/../lib/libLLVMCore.so.15git+0x25e435)
#21 0x00007f4d935018f1 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/local/bin/../lib/libLLVMCore.so.15git+0x2668f1)
#22 0x00007f4d934f9e7c llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/local/bin/../lib/libLLVMCore.so.15git+0x25ee7c)
#23 0x00007f4d963aa2f6 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>>) (/usr/local/bin/../lib/libclangCodeGen.so.15git+0xd62f6)
#24 0x00007f4d967b41e0 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/local/bin/../lib/libclangCodeGen.so.15git+0x4e01e0)
#25 0x00007f4d8fc8ae35 clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/bin/../lib/../lib/libclangParse.so.15git+0x36e35)
#26 0x00007f4d9503c255 clang::FrontendAction::Execute() (/usr/local/bin/../lib/libclangFrontend.so.15git+0x161255)
#27 0x00007f4d94f9e44f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/bin/../lib/libclangFrontend.so.15git+0xc344f)
#28 0x00007f4d96d7c721 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/local/bin/../lib/libclangFrontendTool.so.15git+0x4721)
#29 0x00005597336e30ca cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/local/bin/clang-15+0x130ca)
#30 0x00005597336e099e ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#31 0x00007f4d94c84692 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::$_1>(long) Job.cpp:0:0
#32 0x00007f4d926d6218 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/local/bin/../lib/libLLVMSupport.so.15git+0xf0218)
#33 0x00007f4d94c83fcd clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/usr/local/bin/../lib/libclangDriver.so.15git+0xcafcd)
#34 0x00007f4d94c3f4d8 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/local/bin/../lib/libclangDriver.so.15git+0x864d8)
#35 0x00007f4d94c3f79e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/local/bin/../lib/libclangDriver.so.15git+0x8679e)
#36 0x00007f4d94c600c5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/local/bin/../lib/libclangDriver.so.15git+0xa70c5)
#37 0x00005597336dfddd clang_main(int, char**) (/usr/local/bin/clang-15+0xfddd)
#38 0x00007f4d920acd90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#39 0x00007f4d920ace40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#40 0x00005597336dd1d5 _start (/usr/local/bin/clang-15+0xd1d5)
clang-15: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 15.0.0 (https://github.com/CTSRD-CHERI/llvm-project.git 578ea4f7ef67d589f0ca7d10ec9e383333567421)
Target: riscv64-none-unknown-elf
Thread model: posix
InstalledDir: /usr/local/bin
clang-15: note: diagnostic msg: 
********************

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

********************
@romameie
Copy link
Author

The same issue occurs with df2e7bd and ed9d996 .

@romameie romameie changed the title RISC-V Assertion failure in SelectionDagBuilder.cpp when compiling lib/builtins/fixdfti.c file from CheriBSD-compiler-rt: `(PartVT.isInteger() || PartVT == MVT::x86mmx) && ValueVT.isInteger() && "Unknown mismatch!"' RISC-V Assertion failure in SelectionDagBuilder.cpp when compiling CheriBSD-compiler-rt with 128bit intrinsics: `(PartVT.isInteger() || PartVT == MVT::x86mmx) && ValueVT.isInteger() && "Unknown mismatch!"' Jun 26, 2024
@romameie
Copy link
Author

The same assertion fails for "fixtfti.c" and "mulvti3.c".

Presumably, there's an issue with 128bit intrinsics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant